title: Python script on ubuntu - OSError: [Errno 12] Cannot allocate memory
body: <p>I am running a script on AWS (Ubunut) EC2 instance.  It's a web scraper that uses selenium/chromedriver and headless chrome to scrape some webpages. I've had this script running previously with no problems, but today I'm getting an error.  Here's the script:</p>
  
  <pre><code>options = Options()
  options.add_argument('--no-sandbox')
  options.add_argument('--window-size=1420,1080')
  options.add_argument('--headless')
  options.add_argument('--disable-dev-shm-usage')
  options.add_argument('--disable-gpu')
  options.add_argument("--disable-notifications")
  
  options.binary_location='/usr/bin/chromium-browser'
  driver = webdriver.Chrome(chrome_options=options)
  
  
  #Set base url (SAN FRANCISCO)
  base_url = 'https://www.bandsintown.com/en/c/san-francisco-ca?page='
  
  events = []
  
  for i in range(1,90):
      #cycle through pages in range
      driver.get(base_url + str(i))
      pageURL = base_url + str(i)
      print(pageURL)
  </code></pre>
  
  <p>When I run this script from ubuntu, I get this error:</p>
  
  <pre><code>  Traceback (most recent call last):
    File "BandsInTown_Scraper_SF.py", line 91, in &lt;module&gt;
      driver = webdriver.Chrome(chrome_options=options)
    File "/home/ubuntu/.local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
      self.service.start()
    File "/home/ubuntu/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
      stdin=PIPE)
    File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
      restore_signals, start_new_session)
    File "/usr/lib/python3.6/subprocess.py", line 1295, in _execute_child
      restore_signals, start_new_session, preexec_fn)
  OSError: [Errno 12] Cannot allocate memory
  </code></pre>
  
  <p>I confirmed that I'm running the same version of Chromedriver/Chromium Browser:</p>
  
  <pre><code>ChromeDriver 79.0.3945.130 (e22de67c28798d98833a7137c0e22876237fc40a-refs/branch-heads/3945@{#1047})
  
  
  Chromium 79.0.3945.130 Built on Ubuntu , running on Ubuntu 18.04
  </code></pre>
  
  <p>For what it's worth, I have this running on a mac, and I do have multiple web scraping scripts like this one running on the same EC2 instance (only 2 scripts so far, so not that much).</p>
  
  <h2>Update</h2>
  
  <p>I'm now getting these errors as well when trying to run this script on ubuntu:</p>
  
  <pre><code>    Traceback (most recent call last):
        File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 141, in _new_conn
          (self.host, self.port), self.timeout, **extra_kw)
        File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 60, in create_connection
          for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
        File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
          for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
      socket.gaierror: [Errno -3] Temporary failure in name resolution
  
  
       During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
      chunked=chunked)
    File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 346, in _make_request
      self._validate_conn(conn)
    File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 852, in _validate_conn
      conn.connect()
    File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 284, in connect
      conn = self._new_conn()
    File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 150, in _new_conn
      self, "Failed to establish a new connection: %s" % e)
  urllib3.exceptions.NewConnectionError: &lt;urllib3.connection.VerifiedHTTPSConnection object at 0x7f90945757f0&gt;: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution
  
      During handling of the above exception, another exception occurred:
  
      Traceback (most recent call last):
        File "/home/ubuntu/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
          timeout=timeout
      ^[[B  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 639, in urlopen
      ^[[B^[[A^[[A    _stacktrace=sys.exc_info()[2])
        File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 398, in increment
          raise MaxRetryError(_pool, url, error or ResponseError(cause))
      urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.bandsintown.com', port=443): Max retries exceeded with url: /en/c/san-francisco-ca?page=6 (Caused by NewConnectionError('&lt;urllib3.connection.VerifiedHTTPSConnection object at 0x7f90945757f0&gt;: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
  
      During handling of the above exception, another exception occurred:
  
      Traceback (most recent call last):
        File "BandsInTown_Scraper_SF.py", line 39, in &lt;module&gt;
          res = requests.get(url)
        File "/home/ubuntu/.local/lib/python3.6/site-packages/requests/api.py", line 75, in get
          return request('get', url, params=params, **kwargs)
        File "/home/ubuntu/.local/lib/python3.6/site-packages/requests/api.py", line 60, in request
          return session.request(method=method, url=url, **kwargs)
        File "/home/ubuntu/.local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
          resp = self.send(prep, **send_kwargs)
        File "/home/ubuntu/.local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
          r = adapter.send(request, **kwargs)
        File "/home/ubuntu/.local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
          raise ConnectionError(e, request=request)
      requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www.bandsintown.com', port=443): Max retries exceeded with url: /en/c/san-francisco-ca?page=6 (Caused by NewConnectionError('&lt;urllib3.connection.VerifiedHTTPSConnection object at 0x7f90945757f0&gt;: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
  </code></pre>
  
  <p>Finally, here's my currently monthly AWS usage, which doesn't show any memory quota being exceed.</p>
  
  <p><a href="https://i.stack.imgur.com/p1sBf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p1sBf.png" alt="enter image description here"></a></p>