title: Selenium webdriver Python on ubuntu SessionNotCreatedException
body: <p>I am trying to create a webdriver object in python3.6/selenium3.141.0/Ubuntu 18.04 LTS (Lightsail Amazon Linux), but when I call the webdriver.Chrome() object, it raises an exception. The code works when I ran it locally using windows (I only have to change the chromedriver to the windows version). The chromedriver is located in /usr/bin/chromedriver and my user has permission to execute it.</p>
  
  <p>========================================================</p>
  
  <p>My code is a web app using Flask and running on gunicorn server and it uses the python threading package.</p>
  
  <p>Thanks in advance!</p>
  
  <hr>
  
  <p>Chromedriver and Chrome versions installed on Ubuntu:
  Chromedriver (chromedriver_linux64.zip from <a href="http://chromedriver.storage.googleapis.com/index.html?path=76.0.3809.126/" rel="nofollow noreferrer">http://chromedriver.storage.googleapis.com/index.html?path=76.0.3809.126/</a>)</p>
  
  <p>Command: chromedriver -v  ; I get its version:
  ChromeDriver 76.0.3809.126 (d80a294506b4c9d18015e755cee48f953ddc3f2f-refs/branch-heads/380
  9@{#1024})</p>
  
  <p>command: google-chrome-stable -version ; I get its version:
  Google Chrome 76.0.3809.132 </p>
  
  <p>according to this site, these are the correct/compatible versions for the 76 release:
  <a href="https://chromedriver.chromium.org/downloads" rel="nofollow noreferrer">https://chromedriver.chromium.org/downloads</a>
  Current Releases
  If you are using Chrome version 77, please download ChromeDriver 77.0.3865.40
  If you are using Chrome version 76, please download ChromeDriver 76.0.3809.126
  If you are using Chrome version 75, please download ChromeDriver 75.0.3770.140
  For older version of Chrome, please see below for the version of ChromeDriver that supports it.</p>
  
  <p>My code:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.common.exceptions import NoSuchElementException, UnexpectedAlertPresentException, TimeoutException
  from selenium.webdriver.chrome.options import Options
  from selenium.webdriver.support.select import Select
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  import chromedriver_binary
  
  ##...(there is another function before to create folders)
  
  def funcCX():
     chrome_options = webdriver.ChromeOptions()
     chrome_options.add_argument('--kiosk-printing')
     chrome_options.add_argument('--disable-gpu')
     chrome_options.add_argument('--headless')
     driver = webdriver.Chrome('/usr/bin/chromedriver', chrome_options=chrome_options)
  </code></pre>
  
  #
  
  <p>These are the commands that I used to install chrome and chromedriver:</p>
  
  <pre><code>wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add 
  echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list
  
  sudo apt-get update 
  sudo apt-get install google-chrome-stable
  google-chrome-stable -version
  
  sudo apt-get install -y unzip xvfb libxi6 libgconf-2-4
  
  wget https://chromedriver.storage.googleapis.com/76.0.3809.126/chromedriver_linux64.zip
  unzip chromedriver_linux64.zip
  
  sudo mv chromedriver /usr/bin/chromedriver
  sudo chown root:root /usr/bin/chromedriver
  sudo chmod +x /usr/bin/chromedriver
  chromedriver -v
  </code></pre>
  
  <p>This is the error message that appears:</p>
  
  <pre><code>Exception in thread Thread-3:
  Traceback (most recent call last):
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 
  603, in urlopen
      chunked=chunked)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 
  387, in _make_request
      six.raise_from(e, None)
    File "&lt;string&gt;", line 2, in raise_from
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 
  383, in _make_request
      httplib_response = conn.getresponse()
    File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
      response.begin()
    File "/usr/lib/python3.6/http/client.py", line 297, in begin
      version, status, reason = self._read_status()
    File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
      raise RemoteDisconnected("Remote end closed connection without"
  http.client.RemoteDisconnected: Remote end closed connection without response
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
      self.run()
    File "/usr/lib/python3.6/threading.py", line 864, in run
      self._target(*self._args, **self._kwargs)
    File "/home/ubuntu/AttCx1/pesquisas.py", line 127, in funcCiweb
      driver = webdriver.Chrome('/usr/bin/chromedriver', chrome_options=chrome_options)
  
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriv
  er.py", line 81, in __init__
      desired_capabilities=desired_capabilities)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/selenium/webdriver/remote/webdriv
  er.py", line 157, in __init__
      self.start_session(capabilities, browser_profile)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/selenium/webdriver/remote/webdriv
  er.py", line 252, in start_session
      response = self.execute(Command.NEW_SESSION, parameters)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/selenium/webdriver/remote/webdriv
  er.py", line 319, in execute
      response = self.command_executor.execute(driver_command, params)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/selenium/webdriver/remote/remote_
  connection.py", line 374, in execute
      return self._request(command_info[0], url, body=data)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/selenium/webdriver/remote/remote_
  connection.py", line 397, in _request
      resp = self._conn.request(method, url, body=body, headers=headers)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/request.py", line 72, in 
  request
      **urlopen_kw)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/request.py", line 150, in
   request_encode_body
      return self.urlopen(method, url, **extra_kw)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/poolmanager.py", line 326, in urlopen
      response = conn.urlopen(method, u.request_uri, **kw)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 641, in urlopen
      _stacktrace=sys.exc_info()[2])
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/util/retry.py", line 368, in increment
      raise six.reraise(type(error), error, _stacktrace)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
      raise value.with_traceback(tb)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 603, in urlopen
      chunked=chunked)
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
      six.raise_from(e, None)
    File "&lt;string&gt;", line 2, in raise_from
    File "/home/ubuntu/att-env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
      httplib_response = conn.getresponse()
    File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
      response.begin()
    File "/usr/lib/python3.6/http/client.py", line 297, in begin
      version, status, reason = self._read_status()
    File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
      raise RemoteDisconnected("Remote end closed connection without"
  urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
  </code></pre>
  
  <p>This message repeats more two times because of another two threads that try to create others webdriver objects using the same code.</p>