title: 504 Gateway Time-out error using Firefox 68.9.0esr in headless mode with GeckoDriver Selenium and Python
body: <p>I made a container image with selenium. I used a <code>ubi image</code> from RedHat as base image.</p>
  <p>I installed the following versions of the geckodriver and Mozilla Firefox</p>
  <ul>
  <li>geckodriver 0.26.0 (e9783a644016 2019-10-10 13:38 +0000)</li>
  <li>Mozilla Firefox 68.9.0esr</li>
  </ul>
  <p>I can run a selenium test on firefox successfully. When I run a headless test, something goes wrong:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;./selenium-test.py&quot;, line 58, in &lt;module&gt;
      check_browser(&quot;FIREFOX&quot;)
    File &quot;./selenium-test.py&quot;, line 26, in check_browser
      driver.get(&quot;http://selenium-hub-cpet-selenium.apps.idc.ont.belastingdienst.nl/grid/console&quot;)
    File &quot;/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py&quot;, line 333, in get
      self.execute(Command.GET, {'url': url})
    File &quot;/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py&quot;, line 321, in execute
      self.error_handler.check_response(response)
    File &quot;/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py&quot;, line 208, in check_response
      raise exception_class(value)
  selenium.common.exceptions.WebDriverException: Message: &lt;html&gt;&lt;body&gt;&lt;h1&gt;504 Gateway Time-out&lt;/h1&gt;
  The server didn't respond in time.
  &lt;/body&gt;&lt;/html&gt;
  
  </code></pre>
  <p>Logs from OpenShift where the container runs:</p>
  <pre><code>09:54:45.599 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
  Failed to open connection to &quot;session&quot; message bus: Address does not contain a colon
  1593770085639   mozrunner::runner       INFO    Running command: &quot;/usr/bin/firefox&quot; &quot;-marionette&quot; &quot;-headless&quot; &quot;-foreground&quot; &quot;-no-remote&quot; &quot;-profile&quot; &quot;/tmp/rust_mozprofileaaKtFi&quot;
  1593770085639   geckodriver::marionette DEBUG   Waiting 60s to connect to browser on 127.0.0.1:34835
  Failed to open connection to &quot;session&quot; message bus: Address does not contain a colon
  Running without a11y support!
  *** You are running in headless mode.
  1593770086616   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
  1593770086616   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: telemetry
  1593770086616   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
  1593770086616   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
  1593770086749   Marionette      TRACE   Received observer notification profile-after-change
  1593770086826   Marionette      TRACE   Received observer notification command-line-startup
  1593770086826   Marionette      TRACE   Received observer notification nsPref:changed
  1593770086826   Marionette      DEBUG   Init aborted (running=false, enabled=true, finalUIStartup=false)
  1593770086938   Marionette      TRACE   Received observer notification toplevel-window-ready
  JavaScript error: undefined, line 14: Error: An unexpected error occurred
  JavaScript error: moz-extension://b2c6e410-fc73-460e-9587-3e165c5ce4ac/lib/picture_in_picture_overrides.js, line 15: Error: Incorrect argument types for pictureInPictureParent.setOverrides.
  JavaScript error: resource:///modules/sessionstore/SessionStore.jsm, line 1325: uncaught exception: 2147746065
  1593770096320   Marionette      TRACE   Received observer notification marionette-startup-requested
  1593770096320   Marionette      TRACE   Waiting until startup recorder finished recording startup scripts...
  1593770096523   Marionette      TRACE   All scripts recorded.
  1593770096524   Marionette      DEBUG   Setting recommended pref apz.content_response_timeout to 60000
  1593770096524   Marionette      DEBUG   Setting recommended pref browser.contentblocking.introCount to 99
  1593770096525   Marionette      DEBUG   Setting recommended pref browser.download.panel.shown to true
  1593770096609   Marionette      DEBUG   Setting recommended pref browser.newtabpage.enabled to false
  1593770096610   Marionette      DEBUG   Setting recommended pref browser.pagethumbnails.capturing_disabled to true
  1593770096611   Marionette      DEBUG   Setting recommended pref browser.search.update to false
  1593770096611   Marionette      DEBUG   Setting recommended pref browser.tabs.disableBackgroundZombification to false
  1593770096611   Marionette      DEBUG   Setting recommended pref browser.tabs.remote.separatePrivilegedContentProcess to false
  1593770096612   Marionette      DEBUG   Setting recommended pref browser.tabs.unloadOnLowMemory to false
  1593770096612   Marionette      DEBUG   Setting recommended pref browser.tabs.warnOnCloseOtherTabs to false
  1593770096612   Marionette      DEBUG   Setting recommended pref browser.tabs.warnOnOpen to false
  1593770096612   Marionette      DEBUG   Setting recommended pref browser.usedOnWindows10.introURL to
  1593770096612   Marionette      DEBUG   Setting recommended pref browser.urlbar.suggest.searches to false
  1593770096613   Marionette      DEBUG   Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
  1593770096613   Marionette      DEBUG   Setting recommended pref dom.disable_beforeunload to true
  1593770096613   Marionette      DEBUG   Setting recommended pref dom.disable_open_during_load to false
  1593770096613   Marionette      DEBUG   Setting recommended pref dom.file.createInChild to true
  1593770096613   Marionette      DEBUG   Setting recommended pref dom.max_chrome_script_run_time to 0
  1593770096613   Marionette      DEBUG   Setting recommended pref dom.max_script_run_time to 0
  1593770096614   Marionette      DEBUG   Setting recommended pref extensions.getAddons.cache.enabled to false
  1593770096614   Marionette      DEBUG   Setting recommended pref extensions.webservice.discoverURL to http://%(server)s/dummy/discoveryURL
  1593770096614   Marionette      DEBUG   Setting recommended pref network.http.prompt-temp-redirect to false
  1593770096614   Marionette      DEBUG   Setting recommended pref network.http.speculative-parallel-limit to 0
  1593770096614   Marionette      DEBUG   Setting recommended pref security.fileuri.strict_origin_policy to false
  1593770096614   Marionette      DEBUG   Setting recommended pref security.notification_enable_delay to 0
  1593770096614   Marionette      DEBUG   Setting recommended pref signon.autofillForms to false
  1593770096615   Marionette      DEBUG   Setting recommended pref signon.rememberSignons to false
  1593770096615   Marionette      DEBUG   Setting recommended pref toolkit.cosmeticAnimations.enabled to false
  1593770096821   Marionette      INFO    Listening on port 34835
  1593770096821   Marionette      DEBUG   Remote service is active
  1593770096914   Marionette      DEBUG   Accepted connection 0 from 127.0.0.1:47282
  1593770096915   geckodriver::marionette DEBUG   Connection to Marionette established on 127.0.0.1:34835.
  1593770096921   Marionette      DEBUG   0 -&gt; [0,1,&quot;WebDriver:NewSession&quot;,{&quot;acceptInsecureCerts&quot;:true,&quot;browserName&quot;:&quot;firefox&quot;}]
  1593770096922   Marionette      WARN    TLS certificate errors will be ignored for this session
  1593770097114   Marionette      TRACE   [4294967297] Frame script loaded
  1593770097117   Marionette      TRACE   [4294967297] Frame script registered
  1593770097210   Marionette      DEBUG   0 &lt;- [1,1,null,{&quot;sessionId&quot;:&quot;f0d2e302-c592-49a6-bca6-4f597f778385&quot;,&quot;capabilities&quot;:{&quot;browserName&quot;:&quot;firefox&quot;,&quot;browserVersion&quot;:&quot;68.9. ... /rust_mozprofileaaKtFi&quot;,&quot;moz:shutdownTimeout&quot;:60000,&quot;moz:useNonSpecCompliantPointerOrigin&quot;:false,&quot;moz:webdriverClick&quot;:true}}]
  1593770097214   webdriver::server       DEBUG   &lt;- 200 OK {&quot;value&quot;:{&quot;sessionId&quot;:&quot;f0d2e302-c592-49a6-bca6-4f597f778385&quot;,&quot;capabilities&quot;:{&quot;acceptInsecureCerts&quot;:true,&quot;browserName&quot;:&quot;firefox&quot;,&quot;browserVersion&quot;:&quot;68.9.0&quot;,&quot;moz:accessibilityChecks&quot;:false,&quot;moz:buildID&quot;:&quot;20200529103754&quot;,&quot;moz:geckodriverVersion&quot;:&quot;0.26.0&quot;,&quot;moz:headless&quot;:true,&quot;moz:processID&quot;:363,&quot;moz:profile&quot;:&quot;/tmp/rust_mozprofileaaKtFi&quot;,&quot;moz:shutdownTimeout&quot;:60000,&quot;moz:useNonSpecCompliantPointerOrigin&quot;:false,&quot;moz:webdriverClick&quot;:true,&quot;pageLoadStrategy&quot;:&quot;normal&quot;,&quot;platformName&quot;:&quot;linux&quot;,&quot;platformVersion&quot;:&quot;4.18.0-147.8.1.el8_1.x86_64&quot;,&quot;rotatable&quot;:false,&quot;setWindowRect&quot;:true,&quot;strictFileInteractability&quot;:false,&quot;timeouts&quot;:{&quot;implicit&quot;:0,&quot;pageLoad&quot;:300000,&quot;script&quot;:30000},&quot;unhandledPromptBehavior&quot;:&quot;dismiss and notify&quot;}}}
  09:54:57.215 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
  09:54:57.216 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session f0d2e302-c592-49a6-bca6-4f597f778385 (org.openqa.selenium.firefox.GeckoDriverService)
  1593770102314   webdriver::server       DEBUG   -&gt; POST /session/f0d2e302-c592-49a6-bca6-4f597f778385/url {&quot;url&quot;: &quot;http://selenium-hub-cpet-selenium.apps.idc.ont.belastingdienst.nl/grid/console&quot;}
  1593770102317   Marionette      DEBUG   0 -&gt; [0,2,&quot;WebDriver:Navigate&quot;,{&quot;url&quot;:&quot;http://selenium-hub-cpet-selenium.apps.idc.ont.belastingdienst.nl/grid/console&quot;}]
  1593770103015   Marionette      TRACE   [4294967297] Received DOM event beforeunload for about:blank
  
  </code></pre>
  <p>I tried the official selenium image, which uses Mozilla version 75 and the same Geckodriver. They make use of ubuntu bionic.</p>
  <p>Is Mozilla Firefox 68.9.0esr not supported with these gecko drivers? Or could it be because of another reason that headless mode doesn't work?</p>