Tutorials · 5 min read
How to Set Up SOCKS5 Proxies in Python (Requests, HTTPX, Scrapy)
A copy-paste guide to configuring SOCKS5 proxies in the three most popular Python HTTP libraries.
Author
Editorial Team
Published
July 17, 2026
Reading time
5 minutes

Requests
pip install "requests[socks]"import requests
proxies = {
"http": "socks5h://user:pass@gate.example.com:7777",
"https": "socks5h://user:pass@gate.example.com:7777",
}
r = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=30)
print(r.json())Always use socks5h — the h routes DNS through the proxy.
HTTPX
pip install "httpx[socks]"import httpx
client = httpx.Client(proxy="socks5://user:pass@gate.example.com:7777")
r = client.get("https://httpbin.org/ip")
print(r.json())Scrapy
Install the middleware:
pip install scrapy-proxiesAdd to your settings.py:
DOWNLOADER_MIDDLEWARES = {
'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
}Set http_proxy and https_proxy environment variables to your socks5h:// URL before running scrapy crawl.
Testing
Every provider gives you a test endpoint. Hit it before running anything else — 90% of "my scraper is broken" tickets are credential typos.
Related SOCKS5 deals & promo codes
All deals →Reader-matched offer
15% + 1GBProxy-Cheap
Proxy-Cheap — 15% Off Residential + Free 1GB
Reader-matched offer
$5 FREEBright Data
Bright Data — $5 Free Credit + 7-Day Trial
Reader-matched offer
30% OFFOxylabs
Oxylabs Residential SOCKS5 — 30% Off First Month
Tags
About the author
Editorial Team
The Best SOCKS5 editorial team independently benchmarks, tests, and audits every SOCKS5 proxy provider we cover. We accept affiliate commissions but never accept paid rankings.
Keep reading
Related articles
TutorialsJul 17, 2026 · 13 min read
How to Test a SOCKS5 Proxy: Speed, Anonymity, and Success Rate
The complete methodology for testing any SOCKS5 proxy before you buy — including DNS leak checks, latency benchmarks, and a real-world success-rate script.
TutorialsJul 17, 2026 · 15 min read
How to Set Up a SOCKS5 Proxy: The Complete Step-by-Step Guide
A practical walkthrough for configuring SOCKS5 in your browser, OS, terminal, and scraping stack — with authentication, DNS-through-proxy, and troubleshooting.
TutorialsJul 17, 2026 · 4 min read
How to Configure SOCKS5 in Chrome and Firefox
Browser-native SOCKS5 setup with and without third-party extensions.