The most popular Python HTTP library. Configure KnoxProxy residential, datacenter, or mobile proxies with two lines of code.
Install the requests library from PyPI.
pip install requestsUse your KnoxProxy dashboard username and password in the proxy URL.
PROXY_USER = "your_username"
PROXY_PASS = "your_password"
proxy_url = f"http://{PROXY_USER}:{PROXY_PASS}@gw.knoxproxy.com:7000"Pass the proxy URL as a dict to the proxies parameter.
import requests
proxies = {
"http": proxy_url,
"https": proxy_url,
}
response = requests.get("https://httpbin.org/ip", proxies=proxies)
print(response.json())Target a specific country by adding it to your username string.
# Country targeting via username flag
proxy_url = f"http://{PROXY_USER}-country-us:{PROXY_PASS}@gw.knoxproxy.com:7000"
# Or via header
response = requests.get("https://httpbin.org/ip",
proxies=proxies,
headers={"X-KnoxProxy-Country": "us"})Each request gets a fresh IP by default. Use session IDs for sticky sessions.
# Sticky session (same IP for up to 30 min)
proxy_url = f"http://{PROXY_USER}-session-abc123:{PROXY_PASS}@gw.knoxproxy.com:7000"Verify the proxy is working by checking your exit IP.
response = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=30)
print(f"Exit IP: {response.json()['origin']}")
print(f"Status: {response.status_code}")"""KnoxProxy + Python requests -- complete working example."""
import requests
PROXY_USER = "your_username"
PROXY_PASS = "your_password"
PROXY_HOST = "gw.knoxproxy.com"
PROXY_PORT = 7000
proxy_url = f"http://{PROXY_USER}:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}"
proxies = {"http": proxy_url, "https": proxy_url}
# Basic request with rotation (new IP each time)
response = requests.get(
"https://httpbin.org/ip",
proxies=proxies,
timeout=30,
)
print(f"Exit IP: {response.json()['origin']}")
# Country-targeted request
us_proxy = f"http://{PROXY_USER}-country-us:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}"
response = requests.get(
"https://httpbin.org/ip",
proxies={"http": us_proxy, "https": us_proxy},
timeout=30,
)
print(f"US IP: {response.json()['origin']}")
# Sticky session (same IP for multiple requests)
session_proxy = f"http://{PROXY_USER}-session-mysession1:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}"
session = requests.Session()
session.proxies = {"http": session_proxy, "https": session_proxy}
for i in range(3):
r = session.get("https://httpbin.org/ip", timeout=30)
print(f"Request {i+1}: {r.json()['origin']}")Default: new IP per request. For sticky sessions, append `-session-{id}` to your username. Sessions last up to 30 minutes for residential, 60 minutes for mobile.
| Problem | Fix |
|---|---|
| ProxyError: Cannot connect to proxy | Verify gateway is gw.knoxproxy.com:7000. Check your firewall allows outbound TCP on port 7000. |
| 407 Proxy Authentication Required | Check credentials in your KnoxProxy dashboard. Make sure username and password are URL-encoded if they contain special characters. |
| ConnectTimeout after 30s | Increase timeout to 60s. If persistent, try a different proxy type or contact support. |
| SSLError: certificate verify failed | Update certifi: pip install --upgrade certifi. Do not use verify=False in production. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
Yes. Install requests[socks] (pip install requests[socks]) and use socks5://USER:PASS@gw.knoxproxy.com:7001 as the proxy URL. SOCKS5 is available on all proxy types.
Each new request.get() call through the gateway automatically gets a fresh IP. For sticky sessions, append -session-{id} to your username to hold the same IP for up to 30 minutes.
requests is synchronous. For async, use aiohttp or httpx with asyncio. Both work with KnoxProxy using the same proxy URL format.
KnoxProxy allows unlimited concurrent connections on all plans. Your limit is your machine and the target site, not the proxy. Use concurrent.futures.ThreadPoolExecutor for parallelism with requests.
Free trial on rotating residential -- 2 minutes setup, no credit card.