On this pageYour ColdProxy connection details
- Your ColdProxy connection details
- Python requests proxy setup
- SOCKS5 with requests
- httpx
- Per-scheme routing with mounts
- SOCKS5 with httpx
- aiohttp proxy setup
- SOCKS5 with aiohttp (aiohttp-socks)
- Rotating vs. sticky sessions
- Rotating (a fresh IP per request)
- Sticky (keep the same IP for a session)
- IP whitelist (no username/password)
- Verify the connection
- Next steps
Setting up a Python proxy looks slightly different in each of the three most common HTTP clients (requests, httpx, and aiohttp), and the httpx API has changed (the old proxies= argument is gone; use proxy= or mounts=). The Python requests proxy pattern is a proxies dict, httpx takes a single proxy= client argument, and aiohttp sets the proxy per request. This page shows how to route each library through your ColdProxy gateway with username/password auth, including rotating vs. sticky sessions and the IP-whitelist alternative. For background on the auth models, see IP whitelisting vs. username/password.
Your ColdProxy connection details
- Gateway host:
gw-{service-id}.coldproxy.com— examples usegw-2312.coldproxy.com; replace2312with your service/package ID (a Use Hostname instead of IP toggle in the client area switches to a direct IP). - Port: any port in
30000-34999(examples use30000). - Protocols: HTTP, HTTPS (TCP) and SOCKS5 (TCP and UDP), auto-detected on the same ports.
- Auth: username/password (HTTP Basic / SOCKS5 auth) or IP whitelist (up to 50 IPs).
The proxy string is gw-2312.coldproxy.com:PORT:USERNAME:PASSWORD, equivalent to USERNAME:[email protected]:PORT.
After an order is delivered, wait about 10-20 minutes for the proxies to authenticate and activate. If your username or password contains reserved characters (@ : # % /), URL-encode them with urllib.parse.quote(value, safe="") before building the proxy URL.
Python requests proxy setup
Pass a proxies dict with both http and https keys pointing at the same ColdProxy endpoint. If you only set http, requests will send HTTPS traffic over your real IP, so always set both:
import requests
proxy = "http://USERNAME:[email protected]:30000"
proxies = {"http": proxy, "https": proxy}
resp = requests.get("https://api.vipv6proxy.com/api/checker/my-ip", proxies=proxies, timeout=30)
print(resp.json()) # confirms the exit IPSOCKS5 with requests
SOCKS5 support requires the PySocks extra. Install it, then use a socks5h:// URL so DNS resolves at the proxy (remote DNS):
pip install "requests[socks]"import requests
proxy = "socks5h://USERNAME:[email protected]:30000"
proxies = {"http": proxy, "https": proxy}
resp = requests.get("https://api.vipv6proxy.com/api/checker/my-ip", proxies=proxies, timeout=30)
print(resp.json())Use socks5h:// (not socks5://) so the hostname is resolved from the proxy's location, avoiding DNS leaks. Background: SOCKS5 vs. HTTPS proxies and the SOCKS5 glossary entry.
httpx
httpx removed the old proxies= argument. For one proxy for all traffic, pass a single proxy= string to the client:
import httpx
proxy = "http://USERNAME:[email protected]:30000"
with httpx.Client(proxy=proxy, timeout=30) as client:
resp = client.get("https://api.vipv6proxy.com/api/checker/my-ip")
print(resp.json())Per-scheme routing with mounts
Use mounts= when you need different transports per scheme or want to exclude certain hosts. Each entry is an httpx.HTTPTransport(proxy=...):
import httpx
proxy = "http://USERNAME:[email protected]:30000"
mounts = {
"https://": httpx.HTTPTransport(proxy=proxy),
"https://": httpx.HTTPTransport(proxy=proxy),
}
with httpx.Client(mounts=mounts, timeout=30) as client:
resp = client.get("https://api.vipv6proxy.com/api/checker/my-ip")
print(resp.json())SOCKS5 with httpx
Install the socks extra, then pass a socks5h:// proxy URL:
pip install "httpx[socks]"import httpx
proxy = "socks5h://USERNAME:[email protected]:30000"
with httpx.Client(proxy=proxy, timeout=30) as client:
resp = client.get("https://api.vipv6proxy.com/api/checker/my-ip")
print(resp.json())httpx accepts both socks5:// and socks5h:// and treats them identically: its SOCKS transport always sends the target hostname to the proxy, so DNS resolves remotely either way (unlike requests, where socks5:// resolves DNS locally). Using socks5h:// keeps your proxy URLs consistent with the cURL and requests examples.
AsyncClient takes the same proxy=/mounts= arguments as Client, so the async versions are identical aside from async with and await client.get(...).
aiohttp proxy setup
aiohttp takes the proxy URL and credentials per request; its built-in support covers http:// proxy URLs (HTTPS targets are tunneled through them). Pass credentials as aiohttp.BasicAuth via proxy_auth (cleaner than inlining them in the URL):
import asyncio
import aiohttp
PROXY = "http://gw-2312.coldproxy.com:30000"
AUTH = aiohttp.BasicAuth("USERNAME", "PASSWORD")
async def main():
async with aiohttp.ClientSession() as session:
async with session.get(
"https://api.vipv6proxy.com/api/checker/my-ip",
proxy=PROXY,
proxy_auth=AUTH,
) as resp:
print(await resp.json())
asyncio.run(main())aiohttp's built-in proxy support takes HTTP proxy URLs only. For SOCKS5 use the aiohttp-socks connector below.
SOCKS5 with aiohttp (aiohttp-socks)
Install aiohttp-socks and build a ProxyConnector from a socks5:// URL, then hand it to the session. Pass rdns=True so the hostname resolves at the proxy (remote DNS); with from_url() it is not enabled by default:
pip install aiohttp-socksimport asyncio
import aiohttp
from aiohttp_socks import ProxyConnector
async def main():
connector = ProxyConnector.from_url(
"socks5://USERNAME:[email protected]:30000",
rdns=True,
)
async with aiohttp.ClientSession(connector=connector) as session:
async with session.get("https://api.vipv6proxy.com/api/checker/my-ip") as resp:
print(await resp.json())
asyncio.run(main())Rotating vs. sticky sessions
ColdProxy encodes geo-targeting and session control in the username, so rotation and stickiness change only the credentials; the host and port stay the same. The username grammar is user-key-value-key-value..., with the password passed as the password field; the full reference is the Username tag scheme.
Rotating (a fresh IP per request)
With no session tag you get a new IP per request. Add a geo tag (for example a country) to rotate within that location:
import requests
# Rotating, country-targeted (US): new exit IP on each request
proxy = "http://user-country-us:[email protected]:30000"
proxies = {"http": proxy, "https": proxy}
for _ in range(3):
r = requests.get("https://api.vipv6proxy.com/api/checker/my-ip", proxies=proxies, timeout=30)
print(r.json()) # IP changes each callSticky (keep the same IP for a session)
A sticky IP needs both a session ID and a duration tag: -session-<id> and -time-<duration>. With only one, the request still rotates:
import requests
# Sticky: same US exit IP for ~10 minutes for session id "481516"
proxy = "http://user-country-us-session-481516-time-10m:[email protected]:30000"
proxies = {"http": proxy, "https": proxy}
for _ in range(3):
r = requests.get("https://api.vipv6proxy.com/api/checker/my-ip", proxies=proxies, timeout=30)
print(r.json()) # same IP across calls within the windowThe same username tags work identically in the httpx and aiohttp examples above; only the username string changes.
The exact tag prefixes shown here (country, session, time, etc.) are configured per product by ColdProxy. Confirm the precise prefixes for your plan in your client area before scripting them. Sticky duration limits: Residential IPv4 (both) support 5s-24h; Residential IPv6 and Datacenter IPv6 support 5s-FOREVER. See Rotating and sticky proxies explained and geo-targeting with proxies.
IP whitelist (no username/password)
If you authorize your server's IP in the client area (up to 50 IPs), connect with just the host and port: no credentials. With IP authentication the proxies are issued in IP:PORT form and geo defaults to Worldwide unless SuperPorts are configured:
import requests
# IP-authenticated: your server's IP is whitelisted, so no user:pass
proxy = "http://gw-2312.coldproxy.com:30000"
proxies = {"http": proxy, "https": proxy}
resp = requests.get("https://api.vipv6proxy.com/api/checker/my-ip", proxies=proxies, timeout=30)
print(resp.json())Username/password and IP authentication can both be active at once. To geo-target IP-auth traffic without username tags, configure SuperPorts to bind country/state/city and session settings to specific port ranges. See IP whitelisting.
Verify the connection
The ColdProxy IP-echo endpoint (https://api.vipv6proxy.com/api/checker/my-ip) confirms the exit IP and that auth works. You can also use the ColdProxy proxy checker and My IP tools to confirm reachability, exit IP, and location. On an IPv6 plan, run the IPv6 checker against your target first; many sites are IPv4-only (no AAAA DNS record) and will not respond over IPv6.
A 407 Proxy Authentication Required error means the credentials were rejected or omitted; re-check the username tags and password (and URL-encode special characters). A 403/429 from the target site is a site-side block, not a proxy auth failure. See Common errors & fixes and Proxy error codes 407, 403, 429, 502 and 504 explained.
Next steps
- Compare plans and start a short paid validation window where eligible on pricing and proxy products.
- Scaling these snippets into a pipeline? See the proxy automation and API integration guide.