How to use a proxy in Python Requests (HTTP/HTTPS & Session pooling)

Updated:

Python's requests library accepts authenticated VinaProxy proxies via a proxies dictionary mapping both 'http' and 'https' schemes to http://user:pass@ip:port. Attaching that dictionary to a persistent requests.Session() reuses underlying TCP sockets for fast, low-overhead web scraping.

Python Requests · HTTP Proxy Format
proxies = {'http': 'http://user:pass@ip:port', 'https': 'http://user:pass@ip:port'}
Private IPv4 (datacenter)
🇺🇸 United States
Available
From
₫20,000 / IP / month
≈ $0.74 · billed in VND
Volume pricing
  • 1 IP₫40,000
  • 5+ IPs₫35,000
  • 10+ IPs₫25,000
  • 20+ IPs₫25,000
  • 50+ IPs₫25,000
  • 100+ IPs₫25,000
  • 200+ IPs₫25,000
  • 500+ IPs₫25,000
  • 1000+ IPs₫22,000
  • 2000+ IPs₫20,000
Buy United States
Private IPv4 (datacenter)
🇻🇳 Vietnam
Available
From
₫20,000 / IP / month
≈ $0.74 · billed in VND
Volume pricing
  • 1 IP₫40,000
  • 5+ IPs₫35,000
  • 10+ IPs₫25,000
  • 20+ IPs₫25,000
  • 50+ IPs₫25,000
  • 100+ IPs₫25,000
  • 200+ IPs₫25,000
  • 500+ IPs₫25,000
  • 1000+ IPs₫22,000
  • 2000+ IPs₫20,000
Buy Vietnam

Formatting the proxies dictionary & reusing Sessions

Calling requests.get() on every URL creates a brand-new TCP connection and TLS handshake each time. Binding your proxy to session = requests.Session() keeps the proxy tunnel open across consecutive requests.

Requests ParameterRecommended SyntaxTechnical Purpose
'http' key'http://user:pass@ip:port'Routes plain HTTP requests through the proxy
'https' key'http://user:pass@ip:port'Uses http:// scheme so urllib3 issues an HTTP CONNECT tunnel for TLS
timeout tupletimeout=(5, 15)5s connect timeout and 15s read timeout prevents hung worker threads
Pool rotationitertools.cycle(proxy_list)Cycles evenly across your dedicated static IP pool

Avoiding common urllib3 & ProxyError pitfalls

  • Always use http:// (not https://) as the proxy URL scheme for both 'http' and 'https' dictionary keys unless your proxy port explicitly requires TLS-over-TLS
  • URL-encode special characters in passwords using urllib.parse.quote(password, safe='')
  • A 407 Proxy Authentication Required error means the username or password in your URL string did not match your dashboard credentials
  • Works identically with httpx.Client(proxy='http://user:pass@ip:port') and aiohttp session.get(url, proxy=...)

Step by step

  1. 1

    Convert ip:port:user:pass to URL syntax

    Use our Proxy Format Converter to transform your VinaProxy list into http://user:pass@ip:port strings.

  2. 2

    Define the proxies dictionary

    Set proxies = {'http': 'http://user:pass@ip:port', 'https': 'http://user:pass@ip:port'} in your Python script.

  3. 3

    Attach to a requests.Session() instance

    Initialize s = requests.Session() and call s.proxies.update(proxies) for persistent Keep-Alive pooling.

  4. 4

    Verify exit IP with a test request

    Run print(s.get('https://vinaproxy.com/api/my-ip', timeout=10).json()) to confirm the active proxy IP.

Frequently asked questions

Why does the 'https' key use 'http://user:pass@ip:port'?

The http:// prefix tells urllib3 how to connect to the proxy server itself (using standard HTTP CONNECT), while your end-to-end traffic to the target https:// website remains fully TLS-encrypted.

How do I rotate 25 static proxies across requests in Python?

Load your 25 proxy URLs into pool = itertools.cycle(PROXIES) and pass proxies={'http': p, 'https': p} per request with polite per-IP rate limiting.

Does VinaProxy meter bandwidth on Python scraping scripts?

No. All Dedicated IPv4 and Static ISP plans include unlimited monthly traffic.

Build an unmetered Python scraping pool

Instant Dedicated IPv4 and Static ISP proxies across 7 countries.

Buy Python Proxies

Related articles

Proxies by platform
Proxies for Web Scraping: unmetered dedicated IPv4 & ISP pools for 24/7 crawlers
High-speed HTTP(S) dedicated IPv4 and Static ISP proxies for Python, Playwright, Selenium, and Scrapy with unlimited monthly bandwidth.
Proxy setup
How to set up a proxy in Playwright (Browser & Per-Context Auth)
Configure authenticated HTTP(S) proxies in Playwright for Node.js and Python. Run multiple isolated static IPs across BrowserContexts.
Proxy setup
How to set up and rotate proxies in Python Scrapy
Configure authenticated HTTP(S) proxies in Python Scrapy using HttpProxyMiddleware, request.meta['proxy'], and per-IP concurrency throttling.
Free tools
Bulk Proxy Format Converter (100% Client-Side)
100% client-side bulk proxy list formatter. Convert between ip:port:user:pass, user:pass@ip:port, http:// URLs, SOCKS5 URIs, JSON arrays, and FoxyProxy exports.
Proxies by platform
Proxies for SEO & SERP Tracking: accurate keyword rankings across 7 countries
Track localized keyword rankings, audit geo-redirects, and run Screaming Frog crawls with unmetered dedicated IPv4 and Static ISP proxies.
Proxies by platform
Proxies for Amazon: prevent related-account flags across Seller Central, KDP, and Merch
Prevent Amazon related-account suspensions on Seller Central, KDP, and Merch. Dedicated US Static ISP and UK/Japan private IPv4 proxies.
IPV4 · united states
US Private IPv4 Proxies: Fast, Dedicated American Datacenter IPs
Dedicated US private IPv4 proxies for scraping, rank tracking, ad checks and Amazon research. Static IP, one user per IP, unlimited bandwidth, fast activation.
IPV4 · vietnam
Vietnam Private IPv4 Proxies: Low-Cost Dedicated IPs for Volume Work
Vietnam private IPv4 proxies at a low cost per IP for Facebook seeding, secondary Shopee shops, automation tools and google.com.vn tracking. Unlimited data.