Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I have extracted the following code from selenium IDE.(c# remote control)

using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using Selenium;  namespace SeleniumTests { [TestFixture] public class MyFirstVCTest {     private ISelenium selenium;     private StringBuilder verificationErrors;      [Test]     public void TheNewTest()     {         selenium.Open("/");     }       [SetUp]     public void SetupTest()     {         selenium = new DefaultSelenium("localhost", 4444, "*chrome","http://demo.volunteercampaigns.com/");         selenium.Start();         verificationErrors = new StringBuilder();     }      [TearDown]     public void TeardownTest()     {         try         {             selenium.Stop();         }         catch (Exception)         {             // Ignore errors if unable to close the browser         }         Assert.AreEqual("", verificationErrors.ToString());     }      [Test]     public void TheMyFirstVCTest()     {         selenium.Open("/?AspxAutoDetectCookieSupport=1");         selenium.Click("link=Login");         selenium.WaitForPageToLoad("30000");         selenium.Type("id=ctl00_ContentPlaceHolder1_txtEmailAddress", "[email protected]");         selenium.Type("id=ctl00_ContentPlaceHolder1_txtPassword", "orbs123");         selenium.Click("id=ctl00_ContentPlaceHolder1_btnlogin");         selenium.WaitForPageToLoad("30000");         selenium.Click("id=ctl00_lblUserName");         selenium.Click("id=ctl00_lnkSignOut");         selenium.WaitForPageToLoad("30000");     } } } 

i created a webform and added a button there.

in button click event i wrote this code

SeleniumTests.MyFirstVCTest m = new SeleniumTests.MyFirstVCTest();     m.SetupTest();     m.TheMyFirstVCTest();     m.TeardownTest(); 

i included all .dll files. its running fine(no errors and warnings).

but after clicking button i am getting the following error

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

what should i do??

thanks in advance..

Note to viewers: This post may help you : No connection could be made because the target machine actively refused it

like image 472
Ranadheer Reddy Avatar asked Mar 28 '12 07:03

Ranadheer Reddy


People also ask

How do you fix no connection could be made because target machine actively refused it?

You can try below solution: You might have a firewall rule in the way, or are trying to run it through a proxy without having the proxy up and running. The easiest way to check would be to disable your firewall or proxy and try again. Disable proxy at web.

How do you fix no connection could be made because the target machine actively refused it 10061?

Try running netstat -anb from the command line to see if there's anything listening on the port you were entered. If you get nothing, try changing your port number and see if that works for you. In Windows operating systems, you can use the netstat services via the command line (cmd.exe) .

Could not connect to server No connection could be made because the target machine actively refused it Connection failed Winscp?

“No connection could be made because the target machine actively refused it.” Generally, it happens that something is preventing a connection to the port or hostname. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that specific port.


2 Answers

"...the target machine actively refused it" means the server could be reached and responded within the timeout, but the specified port wasn't open. This can have several reasons, e.g. a local firewall blocking the connection. Are you sure the server is listening on the right IP/port?

like image 198
Mario Avatar answered Sep 16 '22 16:09

Mario


To add more clarity for the readers: Start selenium server using the followings basic steps:

  • Download selenium -server standalone from official selenium download page.
    • Open command prompt.
    • Navigate to the folder using "Cd ".
    • Add this command: "java - jar ".
    • Hit enter.
    • Selenium server will be started.
like image 43
Ayyappadas Avatar answered Sep 17 '22 16:09

Ayyappadas