Python · setup guide

Python Requests proxy setup

Requests takes a dictionary of scheme to proxy URL, and most of the bugs people bring to Discord come from two keys in that dictionary. The other surprise is that a Session quietly keeps your IP.
You will need

Residentialresi.proxymonkey.io:8000

ISP or datacenterIP:PORT

CredentialsUSER:PASS

Copy your own from the dashboard, which also lists the host and port for every order. Where it differs from this page, the dashboard is right.

Install

Python 3.9 or newer.

terminal
pip install requests

Rotating residential

Both keys point at the same http:// URL, including the https key: that key says which target URLs use the proxy, not how to talk to it. Calling requests.get without a session opens a new connection each time, so each line should print a different address.

rotate.py
import requests

PROXY = "http://USER:[email protected]:8000"
proxies = {"http": PROXY, "https": PROXY}

for _ in range(3):
    r = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=(10, 30))
    print(r.json()["origin"])

A static datacenter or ISP IP

On a static datacenter IP you want connection reuse, because a new IP per request is not the point, so use a Session. For an ISP order, swap in the host and port your dashboard shows for it.

static.py
import requests

PROXY = "http://USER:PASS@IP:PORT"

with requests.Session() as s:
    s.proxies.update({"http": PROXY, "https": PROXY})
    for url in ["https://httpbin.org/ip", "https://httpbin.org/headers"]:
        r = s.get(url, timeout=(10, 30))
        print(r.status_code, r.text[:80])

Keeping one identity

A requests.Session pools connections, and an HTTPS request through a proxy rides a tunnel that exits from one address. Reuse the tunnel and you reuse the IP, even on the rotating gateway. That is handy when you want a few requests to one site from the same address, and confusing when you expected rotation. For a residential IP that holds across new connections too, use a sticky session; the session setting for your account is in the dashboard.

Specific to Python Requests

Things worth knowing

Always pass a timeout

Requests has no default timeout, so a stalled connection can hang a script forever. A tuple sets connect and read separately: timeout=(10, 30).

Encode awkward passwords

A password containing @, : or / breaks the proxy URL. Quote each part before you build it.

proxy_url.py
from urllib.parse import quote

user, password = "USER", "PASS"
PROXY = f"http://{quote(user, safe='')}:{quote(password, safe='')}@resi.proxymonkey.io:8000"

Environment variables win quietly

Requests reads HTTPS_PROXY and HTTP_PROXY from the environment. If a stale one is set in your shell, it can route traffic you did not mean to route. session.trust_env = False turns that off.

len(r.content) is not what you are billed

r.content is the decompressed body. The meter counts request bytes plus response bytes on the wire, headers included, so compressed pages can bill less than their decoded size and small pages bill more.

When it breaks

Common errors and fixes

  • ProxyError: ... Tunnel connection failed: 407 Proxy Authentication Required

    Why
    Wrong credentials, an unencoded special character, or a trailing newline read in from a .env file.
    Fix
    Strip and quote the credentials, then print the proxy URL with the password masked to check it.
  • SSLError: [SSL: WRONG_VERSION_NUMBER]

    Why
    The proxy URL starts with https://. Recent urllib3 then tries to speak TLS to the gateway itself, which expects plain HTTP.
    Fix
    Use http:// for the proxy URL under both keys. The tunnel to an HTTPS site is still encrypted end to end.
  • ReadTimeout or ConnectTimeout

    Why
    A slow residential exit, or a target that throttles you by holding the connection open.
    Fix
    Catch both, retry once or twice, and on rotating residential the retry leaves from a different IP.
  • SSLError: CERTIFICATE_VERIFY_FAILED

    Why
    The target's certificate, or an outdated certifi bundle. The proxy does not touch TLS on a CONNECT tunnel.
    Fix
    pip install -U certifi. verify=False is for a one-off test, never for anything you keep.

A failed connection that moved no data is not billed. Retries you send are billed like any other request, and each shows as its own line in your usage log.

The community layer

Python Requests still misbehaving?

Paste the error and the few lines that set up the proxy into Discord, with the password taken out. Someone there has seen it before.

Join the Discord

4,200+monkeys in the Discord

  • Help from humans

    Post your error, get an answer. Usually in minutes, usually from someone who has hit the same wall.

  • A status bot that tells on us

    Pool health, incidents and maintenance posted automatically. Including the bad days.

  • Deals and free traffic

    Bonus GB drops, early access to new pools, and the occasional giveaway for a good bug report.

Join the Discord4,200+ monkeys, free to lurk