DEV Community

Gabriele
Gabriele

Posted on

Debugging a Python requests proxy issue: works in curl but fails in script

While debugging a Python script that sends HTTP requests through a proxy, I ran into a strange issue.

The proxy works perfectly when tested with curl:

curl -x http://user:pass@proxy:port https://quantumproxies.io

This returns the correct IP, so the proxy itself is clearly working.

However the equivalent Python code fails:


python
import requests

proxy = "http://user:pass@proxy:port"

proxies = {
    "http": proxy,
    "https": proxy
}

url = "https://httpbin.org/ip"

response = requests.get(
    url,
    proxies=proxies
    timeout=10
)

print(response.json())
Enter fullscreen mode Exit fullscreen mode

Top comments (0)