Search code examples
pythonpython-requestsufw

Unable to make requests on 443 via python script after ufw installed


I have setup ufw to allow traffic on 443, here are rules

sudo ufw status Status: active

To                         Action      From
--                         ------      ----
443/tcp                    ALLOW       Anywhere
443 (v6)                   ALLOW       Anywhere (v6)

443/tcp                    ALLOW OUT   Anywhere
443/tcp (v6)               ALLOW OUT   Anywhere (v6)

I am writing a simple script to get response code of

https://google.com

Here is the stacktrace.

File "/home/username/.local/lib/python2.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/home/username/.local/lib/python2.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f8633926350>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

Any idea what is going wrong?

I have enabled 443 using

sudo ufw allow out https

Solution

  • Seems a DNS problem according to the error message. Try allowing DNS requests