No connection could be made because the target machine actively refused it

6,480 views
Skip to first unread message

Al Fenkner

unread,
Mar 2, 2011, 2:10:55 PM3/2/11
to Selenium Users
I have a fairly extensive background with Selenium in both Java and C#
shops and normally when I would see this type of error I would be
reminded to start the Selenium proxy server. We have recently
upgraded to Selenium 2 which no longer requires the proxy but I am now
seeing the following stack trace. This doesn't seem to be a
widespread problem with our current code base on other development and
deployment machines in our shop so, it leads me to believe it's a
configuration issue. The exception seems straight forward in that
there is no service listening but Selenium 2 does not proxy the
connections like it used to. Any suggestions would be greatly
appreciated.

Stack Trace:

System.Exception : Cannot open('http://www.[removed].com/search/
#170').
----> OpenQA.Selenium.WebDriverException : Unexpected error.
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: No connection could be made
because the target machine actively refused it [My IP was here]:7055
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext&
context)
at System.Net.HttpWebRequest.GetRequestStream()
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command
commandToExecute) in e:\Projects\WebDriver\trunk\dotnet\src
\WebDriver.Remote\HttpCommandExecutor.cs:line 76
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(DriverCommand
driverCommandToExecute, Dictionary`2 parameters) in e:\Projects
\WebDriver\trunk\dotnet\src\WebDriver.Remote\RemoteWebDriver.cs:line
769

afenkner

unread,
Mar 4, 2011, 2:34:06 PM3/4/11
to seleniu...@googlegroups.com
I knew this had to be a local configuration problem and I eventually figured it out on my own.  My hosts file had my actual IP set for localhost rather than the loop-back IP of 127.0.0.1.  I don't know why or how this got set but I wouldn't have done that.  So, I corrected the problem by replacing my actual IP with the loop-back IP and the problems went away.  

Al Fenkner

unread,
Jul 17, 2012, 12:44:12 PM7/17/12
to seleniu...@googlegroups.com
Do you have to go through a proxy server?  If so, make sure your proxy settings bypass localhost addresses (click Windows Start, type proxy, press enter, click the LAN settings button).  I had this issue a few months ago so I don't remember all of the troubleshooting steps I went through.  Also, if you are setup on a proxy you will need to let the Web Driver know about it if you're hitting external addresses.  If you have any software firewall make sure it's letting the listener shake hands.

I hope this helps and I wish I had a more definitive answer for you.

-Al


On Tuesday, July 17, 2012 8:28:12 AM UTC-7, Sanjit Misra wrote:
Hi Al
 
I was getting the same error as you and tried out the solution that you had proposed. But even after changing the localhost entry to the loopback URL, the problem persists. Any suggestions are highly welcome.
 
I am using the .NET WebDriver v 2.24 and the InternetExplorerDriver in VS 2010.
 
Thanks
Sanjit

misra....@gmail.com

unread,
Jul 17, 2012, 1:50:10 PM7/17/12
to seleniu...@googlegroups.com
Hi Al

Thanks for the quick response.
I found the solution in a bit of a convoluted way. The first step was
1. Changing the host file entry for the local host.
2. Removing the json dll from the Project References (don't know if it has any bearing on the issue)
3. Set the IE security settings to the lowest.
4. In code, use the DesiredCapabilities.SetCapability("ignoreProtectedModeSettings") construct while instantiating the InterneyWebDriver object.

After these steps, the code started working. Probably I should also mention that I am using Selenium along with Telerik Test Studio test engine and as such was a little worried if the engine and selenium drivers were in conflict. Thank God that was not the case.

Thanks for your prompt response.
Sent from BlackBerry® on Airtel

From: Al Fenkner <fen...@gmail.com>
Date: Tue, 17 Jul 2012 09:44:12 -0700 (PDT)
Subject: [selenium-users] Re: No connection could be made because the target machine actively refused it
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/hZgHoj7t5vUJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Sujee

unread,
Jun 18, 2013, 11:50:58 AM6/18/13
to seleniu...@googlegroups.com
Hi All,

I'm new to Selenium. I also faced a similar problem.

In my case, I'm able to open the URL of the application. But I'm getting this issue when the below line of code is executed.

IWebElement element = driver.FindElement(By.CssSelector("span.ui-icon ui-icon-seek-next"));

Can anyone kindly guide me on this?

Thanks In Advance
Reply all
Reply to author
Forward
0 new messages