WebDriverException: Message: 'Can not connect to the ChromeDriver'. Error in utils.is_connectable(self.port):


For Linux

1. Check you have installed latest version of chrome brwoser-> "chromium-browser -version"
2. If not, install latest version of chrome "sudo apt-get install chromium-browser"
3. get appropriate version of chrome driver from following link http://chromedriver.storage.googleapis.com/index.html
4. Unzip the chromedriver.zip
5. Move the file to /usr/bin/ directory sudo mv chromedriver /usr/bin/
6. Goto /usr/bin/ directory and you would need to run something like "chmod a+x chromedriver" to mark it executable.
7. finally you can execute the code.

import os
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
driver = webdriver.Chrome()
driver.get("http://www.google.com")
print driver.page_source.encode('utf-8')
driver.quit()
display.stop()

Verify the line 127.0.0.1 localhost is added to your /etc/hosts file and uncommented. This was the issue for some of my colleagues, and I was able to reproduce it after I've removed this line. Adding it back solved the problem.


open /etc/hosts file and check 127.0.0.1 localhost have matched