When your Python script starts hitting rate limits or getting blocked mid-scrape, the fix is usually a proxy. The Python Requests library makes it straightforward to route your traffic through one, and once you understand the setup, adding proxy support to any script takes just a few lines of code.
In this article, we'll explore how to configure proxies with Python Requests, from basic HTTP proxies to rotating residential ones.
How to Set Up a Proxy in Python Requests

The Requests library handles proxies through a simple dictionary you pass into your request:
1import requests
2
3proxies = {
4 "http": "http://username:password@proxy_ip:port",
5 "https": "http://username:password@proxy_ip:port"
6}
7
8response = requests.get("https://example.com", proxies=proxies)
9print(response.text)
If your proxy doesn't require authentication, remove the username and password from the URL. To apply the proxy across every request without passing it manually each time, use a session:
1session = requests.Session()
2session.proxies.update(proxies)
3
4response = session.get("https://example.com")
5print(response.text)
Sessions are the cleaner approach when making multiple requests since you set the proxy once and forget about it.
Also Read: How to Rotate Proxies in Python Requests (2026)
How to Use Rotating Proxies With Python Requests

Rotating proxies cycle through a pool of IPs automatically so the target website never sees the same source twice. Most services give you a single endpoint that handles rotation on their end:
1import requests
2
3proxies = {
4 "http": "http://username:password@rotating.proxyon.io:port",
5 "https": "http://username:password@rotating.proxyon.io:port"
6}
7
8for i in range(10):
9 response = requests.get("https://example.com", proxies=proxies)
10 print(response.text)
Every iteration hits a different IP without any extra work on your end. If you prefer managing your own list:
1import requests
2import random
3
4proxy_list = [
5 "http://username:password@ip1:port",
6 "http://username:password@ip2:port",
7 "http://username:password@ip3:port"
8]
9
10for i in range(10):
11 proxy = random.choice(proxy_list)
12 proxies = {"http": proxy, "https": proxy}
13 response = requests.get("https://example.com", proxies=proxies)
14 print(response.text)
For most use cases, a managed residential rotating proxy is the better option since you're not dealing with dead IPs or maintaining the list yourself.
How to Test If Your Proxy Is Working

Before running your full script, it's worth confirming that your proxy is actually routing traffic correctly. The easiest way is to send a request to an IP-checking endpoint and see what comes back:
1import requests
2
3proxies = {
4 "http": "http://username:password@proxy_ip:port",
5 "https": "http://username:password@proxy_ip:port"
6}
7
8response = requests.get("https://api.ipify.org?format=json", proxies=proxies)
9print(response.json())
If the IP returned matches your proxy and not your real machine, the proxy is working. If it returns your actual IP, something in your configuration is wrong.
To make this cleaner, you can wrap it in a quick function you run before anything else:
1def test_proxy(proxies):
2 try:
3 response = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=5)
4 print("Proxy working. IP:", response.json()["ip"])
5 except requests.exceptions.RequestException as e:
6 print("Proxy failed:", e)
7
8test_proxy(proxies)
If the proxy fails, you'll get a clear error instead of your script running silently on your real IP. This is especially useful with rotating proxies since you can run it a few times to confirm the IP is actually changing between requests.
Also Read: Python Web Scraping Tutorial (2026)
Final Words
Setting up proxies with Python Requests is straightforward once you have the basics down. For simple tasks, a static proxy gets the job done, but for scraping at scale, rotating residential proxies are the way to go. Proxyon's residential proxies start at $1.75/GB with no subscription required, deposit $5, and start scraping in minutes at Proxyon.





