title: Headless Selenium on Ubuntu Server
body: <p>I currently have selenium installed on a ubuntu 20.04.2 server and I am unable to get it to work, I am not sure what I am missing here</p>
  <p>This is the current python code, I've tried it with and without each one of the options below</p>
  <pre><code>from selenium import webdriver
  from selenium.webdriver.firefox.options import Options
  
  firefox_options = webdriver.FirefoxOptions()
  firefox_options.add_argument(&quot;-headless&quot;)
  firefox_options.add_argument(&quot;--screenshot&quot;)
  firefox_options.add_argument(&quot;--no-sandbox&quot;)
  firefox_options.add_argument(&quot;--disable-dev-shm-usage&quot;)
  firefox_options.add_argument(&quot;-disable-gpu&quot;)
  
  browser = webdriver.Firefox(executable_path=&quot;./drivers/geckodriver&quot;, options=firefox_options)
  
  browser.get('http://www.google.com')
  </code></pre>
  <p>This is the python error code:</p>
  <pre><code>simple.py:11: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
    browser = webdriver.Firefox(executable_path=&quot;./drivers/geckodriver&quot;, options=firefox_options)
  Traceback (most recent call last):
    File &quot;simple.py&quot;, line 11, in &lt;module&gt;
      browser = webdriver.Firefox(executable_path=&quot;./drivers/geckodriver&quot;, options=firefox_options)
    File &quot;/usr/lib/python3/dist-packages/selenium/webdriver/firefox/webdriver.py&quot;, line 170, in __init__
      RemoteWebDriver.__init__(
    File &quot;/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py&quot;, line 152, in __init__
      self.start_session(capabilities, browser_profile)
    File &quot;/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py&quot;, line 249, in start_session
      response = self.execute(Command.NEW_SESSION, parameters)
    File &quot;/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py&quot;, line 318, in execute
      self.error_handler.check_response(response)
    File &quot;/usr/lib/python3/dist-packages/selenium/webdriver/remote/errorhandler.py&quot;, line 242, in check_response
      raise exception_class(message, screen, stacktrace)
  selenium.common.exceptions.TimeoutException: Message: Connection refused (os error 111)
  </code></pre>
  <p>And this is the geckodriver log:</p>
  <pre><code>1614163729970   geckodriver     INFO    Listening on 127.0.0.1:50115
  1614163730921   mozrunner::runner       INFO    Running command: &quot;/snap/bin/firefox&quot; &quot;--marionette&quot; &quot;-headless&quot; &quot;--&gt;
  *** You are running in headless mode.
  [GFX1-]: glxtest: libpci missing
  [GFX1-]: glxtest: Unable to open a connection to the X server
  [GFX1-]: glxtest: libEGL initialize failed
  [GFX1-]: No GPUs detected via PCI
  </code></pre>
  <p>The syslog has nothing related to firefox</p>