Developer hub
Proxy Code Examples for Developers
Choose a proxy example for the client you use, from cURL and Python Requests to C# HttpClient, Java, Node.js, Rust or Go. Check protocol support, then configure one endpoint and verify the exit IP in your client.
Test outside the application first
Run a small test from the same machine or container as your application. Use the same destination URL and timeout for the direct and proxied requests. An online tester has its own source IP and may behave differently if the proxy uses IP allowlisting.
- HTTP 407. Check the proxy credentials or source IP against the provider’s authentication settings. Follow the 407 examples for cURL, PHP, Python and Node.js.
- CONNECT tunnel failed. Read the proxy’s CONNECT response alongside the client exit code. Use the cURL CONNECT checks to identify the first failed step.
- Your Squid server is unreachable. If you run the proxy, check that Squid is listening and that its firewall and access rules allow the client’s source IP. See the Squid firewall and access checks.
- The app shows your usual IP. Check whether the process inherited the proxy settings and whether a bypass matches the host. For Node.js, see the proxy environment setup for Bash and PowerShell.
- The route works but timings vary. Keep the timeout fixed and repeat the same request on both routes before changing configuration.
Record the target host, a masked proxy identifier, elapsed time and the first error or response code. Remove credentials, authorization headers and sensitive URL parameters from shared logs.
More integration examples
Planning a production workload? Compare per-IP and per-GB costs before scaling.
Choose between HTTP CONNECT and SOCKS5
With a standard HTTP CONNECT tunnel, the client establishes TLS with the HTTPS destination through the proxy. A SOCKS5 proxy relays the connection. Check your client’s handling of DNS and authentication before copying options from another library.

Compare the protocol options in the Go transport examples. If your HTTP proxy returns a 407 response, check the proxy authentication guide.
Verified proxy compatibility: versions and test conditions
These results help you choose a client configuration to reproduce. We executed the named libraries and examples against local HTTP and SOCKS5 protocol fixtures that never forwarded traffic to the internet. They verify the listed local configurations, not routing through BuyProxies infrastructure or acceptance by your target website. Original five-client qualification: . The separately dated Node.js supplement below was qualified on .
“Verified” means the expected behavior was observed in the controlled test. “Not tested” means unknown in this qualification. On a narrow screen, focus the table area and scroll horizontally to read all columns. Dates below are UTC.
| Client / version | HTTP destination via HTTP proxy | HTTPS destination via HTTP CONNECT | SOCKS5 | Verified proxy authentication | Environment / test date | Result / limits |
|---|---|---|---|---|---|---|
| Requests 2.34.2 | Verified | Verified | Verified (socks5h) | HTTP Basic; SOCKS username/password | Python 3.12.14; Windows; PySocks 1.7.1; urllib3 2.8.0 | 16/16 expected results. get and Session. Separate guide-configuration reproduction; only socks5h tested. |
| HTTPX 0.28.1 | Verified | Verified | Verified (socks5) | HTTP Basic; SOCKS username/password | Python 3.12.14; Windows; socksio 1.0.0 | 20/20 expected results. Sync and async; four-request batches. No compiled speedups. |
| aiohttp 3.14.5 | Verified | Verified | Not tested | HTTP Basic | Python 3.12.14; Windows | 7/7 expected results. Four-request batches; redirect classification and body-size limit checked. SOCKS unknown here. |
| Scrapy 2.19.0 | Verified | Verified | Not tested | HTTP Basic | Python 3.12.14; Windows; Twisted 26.4.0 | 10/10 expected results. HTTP/1.1 handler; retries and robots.txt checked. Exit 0 alone is insufficient. SOCKS unknown here. |
| n8n 2.42.6 | Verified | Verified | Not tested | HTTP Basic | Node 24.19.0; Windows; HTTP Request node 4.2 | 6/6 expected results. Server CLI and HTTP Request 4.2. Cloud, editor, Docker and SOCKS unknown here. |
What the tests include
All five clients received the expected success response and rejected wrong proxy credentials and an untrusted TLS certificate. Destination 403 responses were distinguished from proxy-authentication failures. Requests, HTTPX, aiohttp and Scrapy also observed a first 302 response without following it. The aiohttp example reports that response as redirect_response; a redirect is not proof of a broken proxy. Scrapy checks included one bounded 503 retry, fixture pool selection and robots.txt exclusion. n8n preserved and exercised the workflow’s 30000 ms timeout.
Configuration and qualification limits
Certificate and hostname verification stayed enabled. Temporary fixture CAs were supplied only to the test processes; successful TLS requests did not disable verification. HTTPS through CONNECT means an HTTPS destination reached through a plain HTTP proxy. A TLS connection to the proxy itself was not tested. HTTPX and aiohttp used official pure-Python wheels imported as ZIPs; Scrapy used ZIP namespace loaders, pure-Python zope.interface and checked compression-extension aliases. These loading conditions are part of the qualification.
Requests used PySocks 1.7.1 with socks5h; a domain-name SOCKS request was observed, but external DNS resolution was not measured. HTTPX used socksio 1.0.0. SOCKS was not tested for aiohttp, Scrapy or n8n. IP allowlisting, remote exit IPs, speed, uptime, other client versions and your destination’s access policy were not qualified. Reproduce a small request from the actual deployment before relying on the configuration.
Official configuration references
- Requests proxies: HTTP proxy URLs, proxy authentication and optional SOCKS support. The documented
socks5andsocks5hschemes differ in where DNS is resolved. - HTTPX proxies: the
proxyparameter, URL credentials and the optional SOCKS dependency. - aiohttp proxy support: HTTP proxies, CONNECT and authentication; version 3.14 deprecates
proxy_authin favor of explicit proxy headers. - Scrapy HttpProxyMiddleware: per-request proxy configuration and handler-dependent support. The tested HTTP/1.1 handler must not be treated as a qualification of the separate HttpxDownloadHandler.
- n8n HTTP Request node: the explicit HTTP Proxy option and timeout setting. This local CLI result does not qualify n8n Cloud.
Download the original five-client compatibility matrix, 12 October 2026 (JSON) for the exact versions, example hashes, dates, controls and limitations. The file contains no proxy endpoints or credentials.
Node.js supplement: 14 October 2026
The following three request paths were executed on Windows with Node.js 24.17.0 against non-forwarding local HTTP/HTTPS services and an authenticated HTTP proxy fixture. They add 30 request controls and two separately labelled native-agent diagnostics. They do not extend the SOCKS or external-exit claims of the original five-client matrix.
| Client / version | HTTP via HTTP proxy | HTTPS via CONNECT | Proxy authentication | Expected results | NO_PROXY / limits |
|---|---|---|---|---|---|
| Built-in fetch Node 24.17.0 / bundled Undici 7.28.0 | Verified | Verified | HTTP Basic | 12/12 | Environment and flag opt-in; direct without opt-in. Exact-host bypass observed; IPv4 dash-range bypass not observed. |
| EnvHttpProxyAgent Undici 7.30.0 | Verified | Verified | HTTP Basic | 10/10 | Exact-host bypass observed; IPv4 dash-range bypass not observed. Dispatcher close retained. |
| Explicit proxy object Axios 1.20.0 | Verified | Verified | HTTP Basic | 8/8 after correction | The explicit proxy object still used the proxy for the NO_PROXY host. Error handling printed an integer HTTP status or a fixed literal, never the full error/config object. |
Each request client was checked for HTTP and HTTPS success, wrong authentication, an untrusted target certificate, target 403, a same-fixture redirect and its unchanged 30-second timeout. TLS verification stayed enabled; the fixture CA was added to child-process trust alongside normal Node roots; the untrusted-certificate controls omitted it. Four original Axios error controls exposed synthetic authentication in process output; the corrected example passed all eight controls without it. Those original observations are retained.
The two distinct native-agent diagnostics observed IPv4 dash-range bypass in the native HTTP agent and no HTTP_PROXY fallback in the native HTTPS agent. Built-in fetch and imported EnvHttpProxyAgent did fall back to HTTP_PROXY when HTTPS_PROXY was absent. SOCKS, HTTPS proxy transport, other versions, physical phones, real exit IPs and throughput were not tested. The POSIX startup commands were checked through Windows process environment/flag equivalence; Linux/macOS shell syntax was not executed.
Read the corrected Node.js examples and dated runtime note, or download the separate anonymous Node.js compatibility supplement (JSON). The original five-client JSON and evidence ZIP remain the dated 12 October artifacts.
Developer checklist
- Keep proxy credentials outside source control.
- Use explicit connect and read timeouts.
- Separate retry logic from proxy rotation logic.
- Retry only safe requests unless your app is idempotent.
- Log status code, proxy ID and elapsed time for every failed request.
- Use the proxy tester before changing code.
Static or rotating proxies for code?
Use static private proxies while building and debugging because the network path stays stable. Add rotation only after the request flow is reliable and the target can tolerate session changes. For logged-in flows, carts and dashboards, sticky sessions are usually safer.
For API testing, proxies are useful for location checks, failover behavior and CDN routing tests. They are not a replacement for proper rate-limit handling.
FAQ
Should proxy credentials be in environment variables?
Yes. Environment variables or secret managers are safer than hardcoding credentials in source files.
Why does cURL work but my code fails?
Your library may use a different proxy format, ignore environment variables, reject the certificate path or use a shorter timeout.
What is the first debugging step?
Test the same proxy and target outside the application, then compare the exact request format.
Download the reproducible evidence bundle (ZIP): the sanitized five-client matrix, anonymous concurrency results, method links, SHA-256 checksums and the HTTPS reproducer. The local compatibility tests and provider-request measurements have separate methods and limits.
Reproduce the PowerShell argument boundary
A local fixture can check command routing and synthetic authentication without contacting a provider. Use the measured Windows PowerShell example to distinguish a zero process exit code from a correctly routed proxy request.
