MaxRetryError Selenium
This error message...
MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=60745): Max retries exceeded with url: /session/900f45d6c8c800f2a8ebcf43daa05b69/url (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa42c261c10>: Failed to establish a new connection: [Errno 61] Connection refused'))
...implies that the ChromeDriver was unable to initiate/spawn/communicate with the Browsing Context i.e. Chrome Browser session.
Root cause
The root cause of this error can be either of the following:
- This error may arise in case manually you are closing the Browsing Context when the driver have already initiated a lookout for element/elements.
- Incase you invoke any WebDriver methods once you have already invoked
driver.close()
ordriver.quit()
. - There is also a possibility that the application you are trying to access is throttling the requests from your system/machine/ip-address/network.
- The application have identified the Selenium driven ChromeDriver initiated google-chrome Browsing Context as a bot and is denying any access.
Solution
Ensure that:
- Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully. - Induce WebDriverWait to synchronize the fast moving WebDriver along with the Browsing Context.
- Selenium is upgraded to current released Version 3.141.59.
- ChromeDriver is updated to current ChromeDriver v84.0 level.
- Chrome is updated to current Chrome Version 84.0 level. (as per ChromeDriver v84.0 release notes)
- If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
References
You can find a couple of relevant detailed discussions in: