I have noticed in my testing that sometimes I get "System.Net.WebException: Unable to connect to the remote server" when running tests in Selenium. It appears to happen randomly, but specifically when running multiple tests at the same time.

My current test set up is using Specflow + specrun. Each test creates a new web driver. Usually there are ~8 test threads running. This error will show up 2-3 times for every 100 tests run.

Has anyone seen this, and does anyone have an idea how to resolve it? My guess is that some other test is already using the same port that the driver is trying to run on, or something similar to that. Anyone know a good way to prevent that?

  • What are your versions? browser and selenium
    – DEnumber50
    Commented Aug 26, 2016 at 19:47
  • Selenium 2.53.1 + PhantomJS 2.1.1 and ChromeDriver 2.23
    – GKS1
    Commented Aug 26, 2016 at 20:13
  • Usually those issues are related to Connectivity/network/domain; have all of these been accounted for?
    – DEnumber50
    Commented Aug 26, 2016 at 20:16
  • Not sure what you mean by that. Any advice on how to ensure that's not the issue?
    – GKS1
    Commented Aug 26, 2016 at 20:20

2 Answers 2


Have a look this, or read this:

  • You are running the test suite twice
  • You are not releasing the connection after each run
  • The test suite crashed and is still running in the background
  • Something else is running on your computer and using that port
  • Do you have any idea how to get around the error when running tests in parallel? It seems the issue is that when I run my test suite, it is launching ~8 drivers at a time, which causes this issue to come up. Running the tests one at a time would be too slow.
    – GKS1
    Commented Aug 29, 2016 at 13:56

Kill the driver instance in cleanup.

You must have made the driver instance static and have not driver.Quit() after the run, so its retailing the instance and not allowing new chromedriver instance to launch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.