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
February 10, 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 proxy deals & promo codes
All deals →Reader-matched offer
$1.99 TRIALSOAX
SOAX — $1.99 Three-Day Test Drive (100MB)
Reader-matched offer
30% OFFOxylabs
Oxylabs Residential Proxies — 30% Off First Month
Reader-matched offer
40% OFF ANNUALDecodo
Decodo Residential — Up To 40% Off Annual Plans
Tags
About the author
Editorial Team
The 5Proxy editorial team independently benchmarks, tests, and audits every proxy provider we cover. We accept affiliate commissions but never accept paid rankings.
Keep reading
Related articles
TutorialsJul 30, 2026 · 13 min read
How to Set Up a SOCKS5 Proxy on Any Device: Windows, macOS, Linux, Android and iOS
A device-by-device walkthrough for configuring SOCKS5 proxies correctly in 2026 — including the DNS leak settings almost every tutorial forgets, and how to verify the connection before you trust it.
TutorialsMar 22, 2026 · 6 min read
How to Test SOCKS5 Proxy Speed and Success Rate
The exact benchmark script we use to test every provider — with copy-pasteable code.
TutorialsMar 18, 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.
More from the 5Proxy library
All articles →tutorials
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.
tutorials
How to Configure SOCKS5 in Chrome and Firefox
Browser-native SOCKS5 setup with and without third-party extensions.
buying guides
SOCKS5 vs HTTP Proxy: Which One Should You Use?
Both proxies forward traffic. Only one is protocol-agnostic and UDP-capable. Here's when to reach for SOCKS5 and when HTTP wins.
tutorials
Scraping Google SERPs with SOCKS5: A Practical Guide
Google's captcha rate scales with datacenter IP density. Residential SOCKS5 is the answer — with the right configuration.
socks5 guides
What Is a SOCKS5 Proxy? A Complete 2026 Guide
SOCKS5 is a low-level proxy protocol that handles any TCP or UDP traffic without inspecting or rewriting it. Here's everything you need to know.
buying guides
Best SOCKS5 Proxies for Instagram Automation (2026)
Instagram's anti-bot pipeline is aggressive. These SOCKS5 providers survive it consistently.