selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service geckodriver
1.version selenium 3.0.0b3 geckodriver-v0.11.1-linux64.tar.gz unpacked to /bin /usr/bin firefox 48.02
2.code:
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
caps = DesiredCapabilities.FIREFOX caps["marionette"] = True caps["binary"] = "/usr/bin/firefox" driver = webdriver.Firefox(capabilities=caps)
3.output:
Traceback (most recent call last): File "test.py", line 3, in browser = webdriver.Firefox() File "/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 68, in init self.service.start() File "/usr/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 92, in start raise WebDriverException("Can not connect to the Service %s" % self.path) selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service geckodriver
4.#cat geckodriver.log 1476111009361 geckodriver INFO Listening on 127.0.0.1:58451
Any idea? Did i miss any step? Bests,
btw
OS: Fedora 23
i post this on mozilla/geckodriver, they say this is selenium issue.
@ShaolongHu where did you ask mozilla? Also this doesn't appear to be an issue in the selenium code base
Same issue here, any progress?
Same Issue: Any update on this? self.driver = webdriver.WebDriverWrapper() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 140, in init self.service.start() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 102, in start raise WebDriverException("Can not connect to the Service %s" % self.path) selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service geckodriver
Some of my colleagues have the exact same issue, but for Chrome driver. Unfortunately, I am not able to reproduce the issue, so it's trickier to debug. I've logged this as well - https://bugs.chromium.org/p/chromedriver/issues/detail?id=1589#c18, but since it happens for Geckodriver as well, could it be a selenium issue?
Same issue reported by some of my colleagues, but with Chromedriver. I read on a forum that it might be due to missing 127.0.0.1 localhost in /etc/hosts file. Does that make any sense for you?
Unfortunately, I am unable to reproduce the issue on my computer, and I'm what of ideas on what to suggest them to do. Any help/idea would be greatly appreciated.
Thank you, Ramona
Ok, I was able to reproduce the issue, and subsequently fix it. Not sure if this is the problem for everyone, but here it goes:
Based on a hunch, I commented out 127.0.0.1 localhost from my /etc/hosts file. And I was able to reproduce the problem, exactly as described here. Afterwards, I added the line back, and Selenium started working again, both with Chromedriver and Geckodriver.
Hope it works for you as well. Please add a comment here if so, so that we know if this was the issue for you as well or not.
it might be due to missing 127.0.0.1 localhost in /etc/hosts file
if localhost is not mapped to its default IP, that would almost certainly cause issues with selenium (and many other programs). But there are infinite ways to misconfigure a system that will cause you networking problems, so I am not sure why this is relevant?
Basically, chromedriver needs to go through localhost to properly run on your computer. I have confirmed with my colleagues that this was the issue for them. Adding this exact value in the hosts file solved the problem. And yes, we need to be very careful not to mess up system files, otherwise we will end up with issues to other apps, and have no clue what's causing them.
@rsuciu-gsg that is correct. My point was that having a misconfigured system is not an issue caused by selenium.
Of course. If this proves to be the same problem for other people on this thread, I think it's safe to assume this issue as an invalid one.
@cgoldberg
Im not sure your point is valid. Note that the entry for 127.0.0.1 localhost is commented out by default in windows host files. Not having this entry is in no way indicative of having a "misconfigured system" and most people wont ever touch that line in the hosts file unless they are running a server like Apache on localhost.
Now, if Selenium requires that 127.0.0.1 localhost to be explicitly set in the host file to work properly, is that requirement documented anywhere? If not, I'd say that missing documentation is the true root cause of this issue for so many people.
@DelightedD0D
if Selenium requires that 127.0.0.1 localhost to be explicitly set in the host file to work properly
Selenium does not require "127.0.0.1 localhost to be explicitly set in the host file". However, it definitely does require "localhost" to be mapped to the IPv4 local loopback (127.0.0.1). The mechanism of this mapping does not have to be via the hosts file. As you pointed out, on Windows it is not mapped in the hosts file at all (resolving localhost is done by the DNS resolver). My point was that if you are misconfiguring this mapping (whether done via /etc/hosts file or via DNS), you should expect to have problems with selenium (and many other programs).
I'd say that missing documentation is the true root cause of this issue for so many people.
I have no idea what the root cause is. "Can not connect to the Service geckodriver" is just a generic timeout error that occurs during startup if the geckodriver service can not be reached within 30 secs.
@DelightedD0D: The ChromeDriver consists of three separate pieces. There is the browser itself ("chrome"), the language bindings provided by the Selenium project ("the driver") and an executable downloaded from the Chromium project which acts as a bridge between "chrome" and the "driver". This executable is called "chromedriver", but it works like a server set up locally. Hence, we do need to map 127.0.0.1 to localhost somewhere. And since is in the chromedriver documentation, although not specified to a more in-depth level of detail, I would say that this is documented... - https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver
Geckodriver works the same way, but not the soon to be late Firefox driver ...
Closing this issue. The original post does not contain enought information to act on. Yes, network misconfiguration can cause connectivity problems, but it's not a selenium issue.
found that running the same code, from command line I can run it smoothly without bug. But when using apache php to run it with system(), the same bug is reported. I have 127.0.0.1 localhost in the config