Solving Selenium chromedriver Error – urllib3.exceptions.ProtocolError: (‘Connection aborted.’, error(10054, ‘An existing connection was forcibly closed by the remote host’))

urllib3.exceptions.ProtocolError: (‘Connection aborted.’, error(10054, ‘An existing connection was forcibly closed by the remote host’)) is an error which occurs in Python and selenium because of incompatibility issues.

In this article we are going to explain why the error is popping up and show you how to solve the error and get rid of it for good.

Explaining the Error : urllib3.exceptions.ProtocolError: (‘Connection aborted.’, error(10054, ‘An existing connection was forcibly closed by the remote host’))

First, we need to reproduce the error, the error can easily be reproduced if your chromdriver version is not compatible with your chrome version while you are trying to use Selenium to access a website.

The example bellow illustrates an example of code that can cause this error.

                                                                       #
from selenium import webdriver
import seleniumimport time
driver = webdriver.Chrome("C:/Python27/chromedriver.exe")
driver.get("https://google.fr")
print(driver.title)
time.sleep(8)
driver.quit()
                                                                       #

Please make sure the error message bellow matches the error you have, you do not want to apply solutions for the wrong problem.

                                                                       #
Traceback (most recent call last):
  File "C:/Users/sohil7777/.PyCharmCE2018.2/config/scratches/scratch.py", line 6, in <module>
....
  File "C:\Python27\lib\site-packages\urllib3\request.py", line 72, in request
    **urlopen_kw)
    response = conn.urlopen(method, u.request_uri, **kw)
....
  File "C:\Python27\lib\site-packages\urllib3\connectionpool.py", line 377, in _make_request
    httplib_response = conn.getresponse(buffering=True)
    response.begin()
....
  File "C:\Python27\Lib\socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
                                                                       #

To solve the problem above, I have 2 solutions which worked for me, bellow is a detailed explanation of both.

Solution : solve incompaibility issues related to ChromeDriver and Chrome

First of all we need to understand that ChromeDriver was unable to initiate a new WebBrowser session.

The root of the issue however, is hard to spot. The problem is the incompatibility between the binaries of

ChromeDriver and the Chrome Browser you are using. At least that is the issue for most developers.

To solve the error you do not need a fancy or complicated fix all you have to do is to upgrade ChromeDriver to the latest version if possible.

The second step is to visit the official site of Chromedriver and read the release note related to that version.

Most of the time the release note specifies the version of chrome version you should have.

Download that chrome version and install it on your machine.

Now, that you have made these changes, you can try to run your code/test. The error should be gone.

The error above was hard to deal with, I spent hours looking for a proper solution or set of solutions.

I hope the solution has been helpful, I hope you solved the error already, you can support us by donating to our Kofi account, this website is free to use but any help is very appreciated and goes a long way.

Summing-up

I can not find any other solution to the problem guys, I tried my best, I hope the above solutions worked for you, cheers, keep coding. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/