Forums

Failed to establish a new connection: [Errno 110] Connection timed out

I am trying to connect my app with an api but urllib3 throws me the following problem. What could be causing this? I have a web dev account.

Error:

(shaas_smarthomy) 13:06 ~/shaas_smarthomy/functions_tuya $ python login.py 
Traceback (most recent call last):
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/urllib3/connection.py", line 358, in connect
    conn = self._new_conn()
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fdd48c90c40>: Failed to establish a new connection: [Errno 110] Connection timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openapi.tuyaus.com', port=443): Max retries exceeded with url: /v1.0/iot-03/users/login (Caused by NewConnectionError('<urllib3.connection.HTTPSConne
ction object at 0x7fdd48c90c40>: Failed to establish a new connection: [Errno 110] Connection timed out'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "login.py", line 22, in <module>
    login_tuya("juan@xxxxx.com","xxxxx","56","xxxxxx")
  File "login.py", line 13, in login_tuya
    status = openapi.connect(username, password)
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/tuya_iot/openapi.py", line 191, in connect
    response = self.post(
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/tuya_iot/openapi.py", line 307, in post
    return self.__request("POST", path, None, body)
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/tuya_iot/openapi.py", line 257, in __request
    response = self.session.request(
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openapi.tuyaus.com', port=443): Max retries exceeded with url: /v1.0/iot-03/users/login (Caused by NewConnectionError('<urllib3.connection.HTTPSCo
nnection object at 0x7fdd48c90c40>: Failed to establish a new connection: [Errno 110] Connection timed out'))

Free accounts can only access http(s) sites on our whitelist. See http://help.pythonanywhere.com/pages/403ForbiddenError/ for details. If the site has a publicly documented API, send us a link to the API documentation and we'll consider it for the whitelist.

I Glenn, my account is not free, I have the dev_web

From some quick experiments, it looks like that site may be blocking access from PythonAnywhere. That's not something we can help with.