Selenium Cannot assign requested address

If you’re using BDD (Cucumber or Behat for example) with Selenium, you may find you occasionally get an error where the framework is unable to communicate with the Selenium server.

Failed to connect to 127.0.0.1: Cannot assign requested address

This seems to occur when there are two many requests going to Selenium. This can be alleviated be rewriting your tests to ensure you are now sending too many requests at once.

For example, if you’re using Behat/Mink, then avoid using the wait() function on the Session object, as this can cause excessive requests to be sent to Selenium.