Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use a proxy with Python Requests, pass a mapping of destination schemes to proxy URLs in the request’s proxies argument. Put proxy credentials in the proxy URL when required, set an explicit timeout, and account for environment proxy settings that can affect a session. Requests does not rotate IP addresses by itself: your code must select among endpoints, or your proxy provider must supply rotation.

How do I use a proxy with Python Requests?

Install Requests if it is not already in your environment:

python -m pip install requests

Then map each destination URL scheme to the proxy URL you want to use. The mapping keys are the schemes of the destination URLs, not the scheme of the proxy itself. A single HTTP proxy URL can be used for both HTTP and HTTPS destinations.

import requests

proxy_url = "http://proxy.example:3128"
proxies = {
    "http": proxy_url,
    "https": proxy_url,
}

response = requests.get(
    "https://example.com",
    proxies=proxies,
    timeout=(5, 20),
)
response.raise_for_status()
print(response.status_code)
print(response.text[:500])

Replace the example host and port with values supplied by your proxy operator. The tuple sets a connect timeout and a read timeout, in seconds. Requests has no timeout by default, so an explicit value helps keep a stalled connection from waiting indefinitely. Choose values appropriate to your application rather than treating these example numbers as universal.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
TP-Link ER605, Wired Gigabit VPN Router
  • 【Five Gigabit Ports】1 Gigabit WAN Port plus 2 Gigabit WAN/LAN Ports plus 2 Gigabit LAN Port. Up to 3 WAN ports optimize bandwidth usage through one device.
  • 【One USB WAN Port】Mobile broadband via 4G/3G modem is supported for WAN backup by connecting to the USB port. For complete list of compatible 4G/3G modems, please visit TP-Link website.
  • 【Abundant Security Features】Advanced firewall policies, DoS defense, IP/MAC/URL filtering, speed test and more security functions protect your network and data.
  • 【Highly Secure VPN】Supports up to 20× LAN-to-LAN IPsec, 16× OpenVPN, 16× L2TP, and 16× PPTP VPN connections.
  • Security - SPI Firewall, VPN Pass through, FTP/H.323/PPTP/SIP/IPsec ALG, DoS Defence, Ping of Death and Local Management. Standards and Protocols IEEE 802.3, 802.3u, 802.3ab, IEEE 802.3x, IEEE 802.1q

Use proxies on an individual call when the choice should be unambiguous for that request. The values must include a scheme, such as http:// or socks5h://; a bare host and port is not a complete proxy URL.

How do I set proxy defaults for a session?

A Session can reuse settings across requests. This is convenient when a group of calls should share a proxy configuration:

import requests

session = requests.Session()
session.proxies.update({
    "http": "http://proxy.example:3128",
    "https": "http://proxy.example:3128",
})

response = session.get("https://example.com", timeout=(5, 20))
response.raise_for_status()

Session defaults are not always the final word. Requests supports proxy environment variables, including http_proxy, https_proxy, no_proxy, and all_proxy, as well as uppercase variants. Environment configuration can override values in session.proxies. If a particular call must use the mapping you chose, pass proxies=... directly to that call and inspect the runtime environment for conflicting settings.

Prepared requests require extra care. Preparing a Request directly does not automatically incorporate environment settings. In a flow that relies on those settings, merge the environment settings into the Session before sending; otherwise, configure the request’s proxy explicitly. This distinction matters when a simple session.get() works but a manually prepared request does not behave the same way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
GL.iNet GL-SFT1200 Opal Travel Router, AC1200 Dual-Band Wi-Fi
  • 【AC1200 Dual-band Wireless Router】Simultaneous dual-band with wireless speed up to 300 Mbps (2.4GHz) + 867 Mbps (5GHz). 2.4GHz band can handles some simple tasks like emails or web browsing while bandwidth intensive tasks such as gaming or 4K video streaming can be handled by the 5GHz band.*Speed tests are conducted on a local network. Real-world speeds may differ depending on your network configuration.*
  • 【Easy Setup】Please refer to the User Manual and the Unboxing & Setup video guide on Amazon for detailed setup instructions and methods for connecting to the Internet.
  • 【Pocket-friendly】Lightweight design(145g) which designed for your next trip or adventure. Alongside its portable, compact design makes it easy to take with you on the go.
  • 【Full Gigabit Ports】Gigabit Wireless Internet Router with 2 Gigabit LAN ports and 1 Gigabit WAN ports, ideal for lots of internet plan and allow you to connect your wired devices directly.
  • 【Keep your Internet Safe】IPv6 supported. OpenVPN & WireGuard pre-installed, compatible with 30+ VPN service providers. Cloudflare encryption supported to protect the privacy.

How do I authenticate to a proxy in Requests?

For HTTP Basic proxy authentication, include the credentials in the proxy URL. Use the username and password issued by the proxy operator:

proxies = {
    "http": "http://USERNAME:[email protected]:3128",
    "https": "http://USERNAME:[email protected]:3128",
}

response = requests.get(
    "https://example.com",
    proxies=proxies,
    timeout=(5, 20),
)

Do not commit a real credential-bearing URL to source control or paste it into logs, error reports, or shared examples. Load secrets at runtime from a controlled secret store and build the proxy URL in memory. If a credential contains URL-reserved characters, encode them correctly as URL components; otherwise, punctuation may be interpreted as part of the URL structure rather than the credential.

Do not confuse proxy authentication with destination-site authentication. The request’s auth= argument is for authentication to the origin service. Credentials in the proxy URL authenticate to the proxy. Requests documents that proxy URL credentials take precedence over a manually supplied Proxy-Authorization header, so avoid setting both unless you have a specific, tested reason.

What is the difference between socks5 and socks5h?

SOCKS support is optional. Install it with:

python -m pip install 'requests[socks]'

Then use a SOCKS URL in the same scheme-to-proxy mapping. The key difference is where DNS resolution occurs:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
ASUS RT-AX1800S Dual Band WiFi 6 Extendable Router, Subscription-Free Network Security, Parental Control, Built-in VPN, AiMesh Compatible, Gaming & Streaming, Smart Home
  • New-Gen WiFi Standard – WiFi 6(802.11ax) standard supporting MU-MIMO and OFDMA technology for better efficiency and throughput.Antenna : External antenna x 4. Processor : Dual-core (4 VPE). Power Supply : AC Input : 110V~240V(50~60Hz), DC Output : 12 V with max. 1.5A current.
  • Ultra-fast WiFi Speed – RT-AX1800S supports 1024-QAM for dramatically faster wireless connections
  • Increase Capacity and Efficiency – Supporting not only MU-MIMO but also OFDMA technique to efficiently allocate channels, communicate with multiple devices simultaneously
  • 5 Gigabit ports – One Gigabit WAN port and four Gigabit LAN ports, 10X faster than 100–Base T Ethernet.
  • Commercial-grade Security Anywhere – Protect your home network with AiProtection Classic, powered by Trend Micro. And when away from home, ASUS Instant Guard gives you a one-click secure VPN.
  • socks5:// resolves the destination hostname on the client.
  • socks5h:// asks the proxy to resolve the destination hostname.

Choose based on where you need name resolution to happen and what the proxy endpoint supports. If SOCKS URLs fail with a missing-dependency error, install the optional extra in the same Python environment that runs your program.

How do HTTPS proxies and certificate verification work?

HTTPS proxying does not mean you should turn off TLS verification. Requests verifies certificates for HTTPS requests by default. Depending on the proxy’s TLS arrangement, your client may also need to trust the proxy’s root certificate. Configure the appropriate CA bundle locally, using the documented REQUESTS_CA_BUNDLE or CURL_CA_BUNDLE setting when applicable.

Avoid verify=False as a routine workaround. It accepts untrusted or mismatched certificates and can expose the connection to man-in-the-middle attacks. If certificate verification fails, establish whether the destination certificate or the proxy’s TLS interception certificate is missing from the trusted bundle, then install the correct CA through your environment’s approved trust process.

How do I rotate proxies in Python Requests?

Requests accepts proxy settings; it does not provide a built-in IP-rotation feature. You can make the selection in your application by choosing a distinct endpoint before each request, or use a provider gateway whose configured behavior selects or changes the exit IP.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
GL.iNet GL-BE3600 Slate 7 Wi-Fi 7 Travel Router Touchscreen 2.5G
  • 【DUAL BAND WIFI 7 TRAVEL ROUTER】Products with US, UK, EU, AU Plug; Dual band network with wireless speed 688Mbps (2.4G)+2882Mbps (5G); Dual 2.5G Ethernet Ports (1x WAN and 1x LAN Port); USB 3.0 port.
  • 【NETWORK CONTROL WITH TOUCHSCREEN SIMPLICITY】Slate 7’s touchscreen interface lets you scan QR codes for quick Wi-Fi, monitor speed in real time, toggle VPN on/off, and switch providers directly on the display. Color-coded indicators provide instant network status updates for Ethernet, Tethering, Repeater, and Cellular modes, offering a seamless, user-friendly experience.
  • 【OpenWrt 23.05 FIRMWARE】The Slate 7 (GL-BE3600) is a high-performance Wi-Fi 7 travel router, built with OpenWrt 23.05 (Kernel 5.4.213) for maximum customization and advanced networking capabilities. With 512MB storage, total customization with open-source freedom and flexible installation of OpenWrt plugins.
  • 【VPN CLIENT & SERVER】OpenVPN and WireGuard are pre-installed, compatible with 30+ VPN service providers (active subscription required). Simply log in to your existing VPN account with our portable wifi device, and Slate 7 automatically encrypts all network traffic within the connected network. Max. VPN speed of 100 Mbps (OpenVPN); 540 Mbps (WireGuard). *Speed tests are conducted on a local network. Real-world speeds may differ depending on your network configuration.*
  • 【PERFECT PORTABLE WIFI ROUTER FOR TRAVEL】The Slate 7 is an ideal portable internet device perfect for international travel. With its mini size and travel-friendly features, the pocket Wi-Fi router is the perfect companion for travelers in need of a secure internet connectivity on the go in which includes hotels or cruise ships.

Application-managed endpoint selection

For a finite list of endpoints, separate selection from the request itself. A round-robin iterator provides a predictable sequence; random selection can choose the same endpoint more than once:

from itertools import cycle
import requests

proxy_urls = [
    "http://proxy-a.example:3128",
    "http://proxy-b.example:3128",
]
if not proxy_urls:
    raise ValueError("At least one proxy endpoint is required")

proxy_cycle = cycle(proxy_urls)

def get_with_next_proxy(url):
    proxy_url = next(proxy_cycle)
    proxies = {"http": proxy_url, "https": proxy_url}
    return requests.get(url, proxies=proxies, timeout=(5, 20))

response = get_with_next_proxy("https://example.com")
response.raise_for_status()

This example only changes which configured endpoint the application uses. It does not test endpoint health, guarantee a different public IP, or retry safely after a failure. Add application-specific failure handling: decide whether to try another endpoint, how many attempts are acceptable, which exceptions merit a retry, and how to avoid repeating a request that may already have reached the destination.

Provider-managed rotation

A provider gateway can let the application keep one proxy URL while the provider selects an exit IP. The exact behavior depends on the purchased product and its settings. Before relying on it, verify the rotation cadence, sticky-session controls, geography, authentication method, and current terms for that precise product. Some provider offerings rotate intrinsically; dedicated endpoints may require a separate mechanism. A provider integration example is not an independent performance test or an endorsement.

Decision point Application-managed endpoints Provider-managed gateway
Who chooses the exit endpoint? Your code selects from the endpoint list according to its policy. The provider selects according to its product configuration.
Repeated IP behavior Random selection can repeat; round-robin gives a predictable endpoint sequence. Depends on the documented rotation and sticky-session controls.
Operational work Maintain endpoints, credentials, selection logic, and failure handling. Configure the gateway and understand its account and session settings.
Geographic choice Depends on the locations of endpoints you have. Depends on the provider’s product and supported targeting controls.

Rotation does not establish that a destination will be reachable, make a request reliable, or guarantee that access controls will be bypassed. Follow the destination’s terms, applicable access rules, and published rate limits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why is Requests ignoring my proxy settings?

Check the configuration in this order:

  1. Confirm the mapping keys. Use http and/or https to match the destination URL’s scheme.
  2. Include a proxy URL scheme. Use a complete value such as http://proxy.example:3128, not just a hostname and port.
  3. Inspect environment variables. Look for lowercase and uppercase proxy variables and no_proxy, which can change which requests use a proxy.
  4. Make the setting explicit. Pass proxies to the individual request if it must use a particular endpoint despite Session or environment configuration.
  5. Check the request path. If you prepare a request manually, remember that preparation alone does not apply environment settings; merge them into the Session when you intend to use them.
  6. Verify the endpoint and credentials. A syntactically valid mapping cannot fix a wrong host, port, scheme, or proxy account credential.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common proxy errors and practical fixes

  • Connection refused or connection error: Confirm the proxy host and port, network reachability, and whether the endpoint accepts the scheme you specified.
  • Proxy authentication failure: Check the operator-issued username and password, confirm the account is allowed to use that endpoint, and ensure special characters are URL-encoded. Do not substitute the destination’s auth= credentials.
  • SOCKS support unavailable: Install requests[socks] in the interpreter or virtual environment running the script.
  • Certificate verification error: Keep verification enabled and configure the needed trusted CA bundle. Do not make verify=False the production fix.
  • Request hangs: Add a connect/read timeout and handle the resulting Requests exceptions. A timeout does not prove the remote server never received the request, so consider that before retrying operations with side effects.
  • Unexpected direct connection or bypass: Inspect environment variables and no_proxy, then pass a per-request mapping when explicit selection is required.

Performance, reliability, and cost considerations

Proxy use adds another network hop, so connection and read times can differ from a direct request. No universal speed or reliability figure follows from the Requests configuration itself; endpoint quality, route, destination, provider settings, and workload all matter. Set timeouts for the application, measure behavior in the environment that will run it, and handle proxy failures explicitly.

Best Value
Sale
TP-Link Dual-Band AX3000 Wi-Fi 6 Wireless Gigabit Internet Router for Home
  • Next-Gen Gigabit Wi-Fi 6 Speeds: 2402 Mbps on 5 GHz and 574 Mbps on 2.4 GHz bands ensure smoother streaming and faster downloads; support VPN server and VPN client¹
  • A More Responsive Experience: Enjoy smooth gaming, video streaming, and live feeds simultaneously. OFDMA makes your Wi-Fi stronger by allowing multiple clients to share one band at the same time, cutting latency and jitter.²
  • Expanded Wi-Fi Coverage: 4 high-gain external antennas and Beamforming technology combine to extend strong, reliable, Wi-Fi throughout your home.
  • Improved Battery Life: Target Wake Time helps your devices to communicate efficiently while consuming less power.
  • Improved Cooling Design: No heat ups, no throttles. A larger heat sink and redefined case design cools the WiFi 6 system and enables your network to stay at top speeds in more versatile environments.

For an endpoint list, account for the work of maintaining inventory, credentials, and health/failure policy. For a gateway, check how the provider charges for traffic or sessions and what its configured rotation means. The Requests and provider integration information discussed here does not establish a particular price, performance level, success rate, pool size, or access outcome.

Or skip the browser setup

If your task is specifically to capture a rendered page rather than route a general Python HTTP request through a proxy, ScreenshotNeo is a separate screenshot API and MCP server. It is not a substitute for configuring a proxy in Requests. Its one-call API can return a screenshot or PDF; see the ScreenshotNeo API documentation.

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)

ScreenshotNeo removes cookie banners, popups, and chat widgets before the shot. Bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free and get 1,000 screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does Python Requests rotate proxies automatically?

No. Requests sends requests through the proxy configuration you provide; endpoint selection or provider-managed rotation must be supplied separately.

Can I use one HTTP proxy URL for an HTTPS destination?

Yes. The proxy mapping key corresponds to the destination scheme, and Requests examples use an HTTP proxy URL for HTTPS destinations.

Does changing proxies guarantee that a request will succeed?

No. A different endpoint does not guarantee access, reliability, or a changed public IP; behavior depends on the endpoint and provider configuration.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.