selenium.common.exceptions.SessionNotCreatedException: Message: Error: NS_ERROR_UNKNOWN_HOST error opening Firefox v103.0.2 with GeckoDriver v0.31.0
Asked Answered
L

0

6

Firefox v103.0.2 (current) when initiated with latest GeckoDriver v0.31.0 and Selenium v4.4.0 crashes with NS_ERROR_UNKNOWN_HOST error as follows:

selenium.common.exceptions.SessionNotCreatedException: Message: Error: NS_ERROR_UNKNOWN_HOST

Code trials:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Log

import sys
print ("Python Version: " +str(sys.version_info))

import selenium
print("Selenium version: " +selenium.__version__)

log = Log()
log.level = "trace"
options = Options()
options.add_argument(log.level)
s = Service('C:\\BrowserDrivers\\geckodriver.exe')
driver = webdriver.Firefox(service=s, options=options)
driver.get('https://www.google.com/')

Console output, traceback and error stacktrace:

Python Version: sys.version_info(major=3, minor=9, micro=0, releaselevel='final', serial=0)
Selenium version: 4.4.0
Traceback (most recent call last):
  File "C:\Users\debanjan.bhattacharj\Desktop\Python Programs\Selenium_Firefox_tests.py", line 26, in <module>
    driver = webdriver.Firefox(service=s, options=options)
  File "C:\Users\user_name\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 177, in __init__
    super().__init__(
  File "C:\Users\user_name\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 276, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\user_name\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 369, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\user_name\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 434, in execute
    self.error_handler.check_response(response)
  File "C:\Users\user_name\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Error: NS_ERROR_UNKNOWN_HOST
Stacktrace:
#checkLoadingState@chrome://remote/content/shared/Navigate.jsm:239:28
onStateChange@chrome://remote/content/shared/Navigate.jsm:284:28

Where am I wrong? Anybody facing the same?

Lowborn answered 13/8, 2022 at 0:16 Comment(5)
you might want to check your HOSTS file for a "localhost" entry. If it is there, it should be set to "127.0.0.1"... if not, try adding that. Sounds like something's blocking localhost from resolving (maybe blocked by port??)Pepperandsalt
I tried to reproduce this on my machine. I was getting the following error: selenium.common.exceptions.SessionNotCreatedException: Message: Error: NS_BINDING_ABORTED Stacktrace: #checkLoadingState@chrome://remote/content/shared/Navigate.jsm:216:28 onStateChange@chrome://remote/content/shared/Navigate.jsm:261:28 But when I commented the line options.add_argument(log.level), I was able to execute the code without any error. I know the error is not the same as you got, but thought to share it in case it helps you resolve this.Conventionality
@Conventionality Please help us to debug and fix the issue by updating your observations in the GeckoDriver issue.Lowborn
@undetectedSelenium I am not able to reproduce this scenario on my machine. I am on Windows, with the Selenium 4.4.0, Python 3.10.2 and the above code is working fine after commenting options.add_argument() line.Conventionality
same issue, any advice?Somniferous

© 2022 - 2024 — McMap. All rights reserved.