Home › Residential proxies › ISP Proxies

Python Requests Proxy: Complete Setup Guide

HTTP/HTTPS/SOCKS5 · sessions · timeouts & retries · rotation patterns · updated 6 November 2026
Tutorials
Home › Tutorials › Python Requests Proxy: Complete Setup Guide

Requests reads proxies from a plain dict passed to any request method. One dict covers every protocol:

import requests

proxies = {
    "http":  "http://USER:PASS@GATEWAY:PORT",
    "https": "http://USER:PASS@GATEWAY:PORT",
}

r = requests.get("https://api.ipify.org", proxies=proxies, timeout=15)
print(r.text)  # your proxy's exit IP
The "https" key does not require an HTTPS proxy — it means "use this proxy for https:// targets". A plain http:// proxy entry handles HTTPS targets via CONNECT, exactly like cURL.

SOCKS5

SOCKS5 needs the socks extra (pulls in PySocks):

pip install "requests[socks]"
proxies = {
    "http":  "socks5h://USER:PASS@GATEWAY:PORT",
    "https": "socks5h://USER:PASS@GATEWAY:PORT",
}

As with cURL, prefer socks5h:// — DNS resolves on the proxy side, eliminating DNS leaks.

Sessions: reuse connections and credentials

For anything beyond a one-off call, use a Session. It pools TCP connections (much faster through a remote gateway) and lets you set the proxy once:

import requests

s = requests.Session()
s.proxies = {"http": "http://USER:PASS@GATEWAY:PORT",
             "https": "http://USER:PASS@GATEWAY:PORT"}
s.headers.update({"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"})

r = s.get("https://target-site.com", timeout=(5, 20))  # (connect, read)

Timeouts and retries that survive production

Proxies add latency and occasionally stall. Always set both connect and read timeouts, and retry idempotent GETs:

from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry

retry = Retry(total=3, backoff_factor=1.5,
              status_forcelist=[429, 500, 502, 503, 504],
              allowed_methods=["GET", "HEAD"])
s.mount("https://", HTTPAdapter(max_retries=retry, pool_maxsize=20))

Rotation patterns

With a rotating gateway, rotation happens server-side — you get a fresh exit IP per request (or per session token):

# new IP per request (gateway rotates)
for page in pages:
    s.get(page, proxies=proxies, timeout=15)

# sticky session: same IP for a burst, then rotate
sticky = proxies.copy()
sticky["http"]  = sticky["http"].replace("USER", "USER-session-7f3a")
sticky["https"] = sticky["https"].replace("USER", "USER-session-7f3a")
Don't build your own rotation layer until you've measured the gateway's. A quick check: fire 50 requests through one entry and count unique exit IPs — see IPLight's published pool report for what a healthy pool looks like.

Debugging checklist

FAQ

Does the https key in proxies need an HTTPS proxy?

No. The key is the target scheme, not the proxy protocol. A plain http:// proxy entry handles https:// targets via CONNECT tunneling.

How do I use SOCKS5 with Requests?

Install the extra with pip install requests[socks], then use socks5h:// in your proxies dict. socks5h resolves DNS on the proxy side, avoiding DNS leaks.

Requests vs httpx for proxies?

Both support the same proxies dict format. httpx additionally supports HTTP/2; Requests has a larger ecosystem. The proxy concepts in this guide apply to both.

How do I verify my proxy actually rotates?

Send 50 requests through one gateway entry and count unique exit IPs. IPLight publishes its measured pool depth openly in the live pool report.

IPLight's rotating residential pool: 215,000+ live IPs, 170+ countries, from $1.20/GB — see pricing or verify the pool in the live pool report.

Test on your own target list

Residential from $1.20/GB · static ISP from $2/IP per month (15+ IPs) · no monthly commitment. Create an account, top up a small balance and run your first requests in minutes.

Create account

Frequently asked questions

How much does it cost?

Dynamic residential traffic starts at $1.20/GB on the 100 GB tier ($120), dropping to $0.96/GB at 1,000 GB, $0.72/GB at 5,000 GB and $0.60/GB at 10,000 GB. Static residential IPs are $3/IP/month, or $2/IP/month from 15 IPs. There are no setup fees or monthly platform fees.

Does traffic count both upload and download?

Yes - traffic is metered in both directions and 1 GB = 1,000 MB. The console shows an hourly usage breakdown per sub-account, so you can audit exactly what each job consumed. Disabling images and video in your crawler cuts usage significantly.

Is there a contract or minimum commitment?

No. Top up once and spend the balance across dynamic traffic, static IPs and unlocking. Paid orders keep their unit price even if the public price list changes later.

Which protocols are supported?

HTTP and SOCKS5 endpoints are provided, with username/password or IP-whitelist authentication. AdsPower, BitBrowser, Python, Node, Scrapy, Playwright and Puppeteer all connect directly.

What is the difference between ISP proxies and static residential proxies?

At IPLight they are the same product: real IP addresses registered to consumer internet service providers, dedicated to your account for the whole term. Some providers sell 'ISP proxies' that are actually datacenter ranges announced by an ISP - ours are checked as residential before they enter inventory.

Can I keep the same IP for months?

Yes. Choose a 30, 90 or 180-day term and the same IP stays assigned to your account for the full term, which is what makes ISP proxies suitable for account management and long-lived logins.

Popular proxy locations: All locations · USA · UK · Germany · Japan · Indonesia · Brazil · India · Russia
Popular products: Residential proxies · ISP proxies · SERP proxies · Static residential · Pricing
IPLight live residential pool: 215,000+ online IPs across 170+ countries & regions · dynamic residential from $1.20/GB · pool sizes measured in real time · updated 2026-11