Generate proxy configuration examples for Python Requests, cURL, Node.js with Undici, PHP cURL and PowerShell 7. Enter an HTTP proxy host and port, choose your authentication method, and copy code for one HTTPS request. The generator works locally in your browser and does not test your proxy.
The initial examples use the reserved placeholder proxy.example:3128 and https://example.com/. Replace the proxy endpoint before running code in your own environment. The HTTPS destination and HTTP connection to the proxy are separate settings.
Build your proxy request
Use the host and port supplied for your HTTP proxy. Enter an HTTPS destination you are allowed to access, without credentials, query parameters or a fragment. Do not paste passwords, access tokens or private URLs into this form.
DNS name, full IPv4 address or IPv6 address. IPv6 brackets are optional. Enter the port separately.
A whole number from 1 to 65535.
This tool generates HTTP proxy connections with CONNECT to an HTTPS destination.
Basic reads PROXY_USER and PROXY_PASS when you run the code. No credential fields are sent to this page.
Example: https://example.com/ or your own approved HTTPS endpoint. Queries, fragments, embedded credentials and control characters are rejected.
Initial placeholder examples are shown below. Enable JavaScript to generate and copy your own settings.
Configuration examples
Each example keeps destination TLS verification enabled, selects the proxy explicitly and does not follow redirects. A received HTTP status is a response observation, not proof of a particular exit address or location. Python uses separate connect and read timeouts; cURL, Node.js, PHP and PowerShell set a total request deadline.
Python Requests
Python 3 with the Requests package. Save the example as proxy_request.py.
# Python 3 with Requests: python -m pip install requests
# Save as proxy_request.py; run: python proxy_request.py
import sys
import requests
target_url = "https://example.com/"
proxy_url = "http://proxy.example:3128"
try:
with requests.Session() as session:
session.trust_env = False
with session.get(
target_url,
proxies={"http": proxy_url, "https": proxy_url},
timeout=(10, 30),
allow_redirects=False,
stream=True,
) as response:
print("HTTP status:", response.status_code)
response.raise_for_status()
except requests.RequestException as error:
print("Request failed:", type(error).__name__, file=sys.stderr)
sys.exit(1)
Continue with the Python Requests proxy guide.
cURL
Run in a POSIX shell such as sh, bash or zsh with cURL and sed available. This shell syntax is not for PowerShell.
# POSIX shell (sh/bash/zsh) with cURL; not PowerShell syntax.
# Save as proxy_request.sh; run: sh proxy_request.sh
curl --disable \
--proxy 'http://proxy.example:3128' \
--noproxy '' --globoff --proto '=https' \
--connect-timeout 10 --max-time 30 \
--silent --show-error --fail \
--output /dev/null --write-out 'HTTP status: %{http_code}\n' \
--url 'https://example.com/'
Continue with the cURL proxy guide.
Node.js and Undici
Use Node.js 20 or newer with undici@6. Save the example with the .mjs extension.
// Node.js 20+ with Undici 6: npm install undici@6
// Save as proxy_request.mjs; run: node proxy_request.mjs
import { ProxyAgent, fetch } from 'undici';
const targetUrl = "https://example.com/";
const dispatcher = new ProxyAgent("http://proxy.example:3128");
try {
const response = await fetch(targetUrl, {
dispatcher,
redirect: "manual",
signal: AbortSignal.timeout(30000),
});
console.log("HTTP status:", response.status);
if (response.body) await response.body.cancel();
if (response.status >= 400) process.exitCode = 1;
} catch (error) {
console.error("Request failed:", error.name);
process.exitCode = 1;
} finally {
await dispatcher.close();
}
Continue with the Node.js Fetch and Undici guide.
PHP cURL
PHP CLI with the cURL extension. Save as proxy_request.php.
<?php
// PHP CLI with the cURL extension; save as proxy_request.php.
// Run: php proxy_request.php
$target = 'https://example.com/';
$proxy = 'http://proxy.example:3128';
$handle = curl_init($target);
$options = array(
CURLOPT_PROXY => $proxy,
CURLOPT_PROXYTYPE => CURLPROXY_HTTP,
CURLOPT_NOPROXY => '',
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_PROTOCOLS => CURLPROTO_HTTPS,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_FAILONERROR => true,
CURLOPT_WRITEFUNCTION => function ($handle, $data) { return strlen($data); },
);
curl_setopt_array($handle, $options);
$result = curl_exec($handle);
$errno = curl_errno($handle);
$status = (int) curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
echo "HTTP status: " . $status . "\n";
if ($result === false) {
fwrite(STDERR, "Request failed; cURL error code: " . $errno . "\n");
exit(1);
}
Continue with the PHP cURL proxy guide.
PowerShell 7
PowerShell 7 using .NET HttpClient and an explicit WebProxy. Save as proxy_request.ps1.
# PowerShell 7; save as proxy_request.ps1.
# Run: pwsh -NoProfile -File ./proxy_request.ps1
$ErrorActionPreference = 'Stop'
$target = 'https://example.com/'
$proxy = [System.Net.WebProxy]::new('http://proxy.example:3128')
$proxy.BypassProxyOnLocal = $false
$proxy.BypassList = @()
$handler = [System.Net.Http.HttpClientHandler]::new()
$handler.Proxy = $proxy
$handler.UseProxy = $true
$handler.UseDefaultCredentials = $false
$handler.AllowAutoRedirect = $false
$client = [System.Net.Http.HttpClient]::new($handler)
$client.Timeout = [TimeSpan]::FromSeconds(30)
$response = $null
try {
$response = $client.GetAsync($target, [System.Net.Http.HttpCompletionOption]::ResponseHeadersRead).GetAwaiter().GetResult()
$status = [int] $response.StatusCode
Write-Output ('HTTP status: ' + $status)
if ($status -ge 400) { exit 1 }
} catch {
[Console]::Error.WriteLine('Request failed: ' + $_.Exception.GetType().Name)
exit 1
} finally {
if ($null -ne $response) { $response.Dispose() }
$client.Dispose()
}
Continue with the PowerShell proxy guide.
Authentication and what these examples establish
For Basic authentication, supply PROXY_USER and PROXY_PASS through your local runtime or secret manager. These examples accept nonempty printable ASCII credentials; the username cannot contain a colon. Python percent-encodes credentials in its proxy URL, Node.js builds the proxy authorization token, and cURL passes an escaped configuration value through standard input. PHP supplies proxy credentials to cURL options; PowerShell attaches a NetworkCredential to its proxy object and can answer a proxy challenge before completing CONNECT. Keep credentials and generated authentication values out of logs and source control.
HTTP transport does not encrypt the connection between your client and the proxy, including Basic proxy authentication. HTTPS protects the destination connection through the tunnel. This generator does not establish support for TLS transport to a Mexela proxy endpoint. Confirm the protocol and authentication available for your assigned endpoint before running the example.
The form does not make network requests, save settings, read cookies or collect interaction analytics. Generating code cannot establish proxy availability, destination acceptance, country, anonymity, DNS privacy, speed or uptime. Verify your own request in your authorized environment and redact private diagnostics before sharing them.
Continue with the developer resources
Open the Proxy Setup and Developer Guides hub for more clients, the public proxy code repository for the separate versioned source examples, or the client compatibility matrix for recorded test scope. Compare current Mexela proxy pricing after confirming the route and authentication your application needs.
Official API references
Tested runtimes and request behavior
Verified on 14 October 2026 using the generated code and an owned local HTTP CONNECT gateway with an HTTPS destination.
- Python 3.12.3 with Requests 2.31.0: 11 runtime cases passed.
- cURL 8.5.0: 11 runtime cases passed.
- Node.js 20.20.2 with Undici 6.29.0: 22 runtime cases passed.
- Node.js 24.19.0 with Undici 6.29.0: 22 runtime cases passed.
Checks covered explicit proxy routing, requests with and without Basic authentication, destination responses 200, 302 and 403, rejected untrusted TLS certificates, and invalid credentials. A destination redirect stayed unfollowed. Node.js checks also covered hostname verification, gateway rejection, credential headers staying off the destination, and connection shutdown.
These local checks describe the versions above. They do not measure a live proxy’s speed, availability or exit location. The Node.js example imports the installed Undici package. Node.js 20 is end of life; its result documents compatibility only. Use a supported LTS release for production, as listed in the official Node.js release schedule.
For dependency setup and troubleshooting, see the Python Requests proxy guide, cURL proxy guide and Node.js and Undici proxy guide.
PHP cURL and PowerShell 7: generated examples and test scope
The two additional cards use the same validated endpoint and HTTPS destination as the Python, cURL and Node.js examples. Credentials are entered only through your own runtime’s PROXY_USER and PROXY_PASS variables, never into this webpage.
The PHP and PowerShell variants were executed on 16 October 2026 against owned loopback CONNECT/TLS fixtures: PHP 8.4.22 and 8.4.26 on Windows, and PowerShell 7.6.7 on Linux. Each run contains 24 cases across the two clients, including authentication, destination statuses, rejected certificates and credential failures. The existing three generated outputs remain byte-identical for the same input.
See the version and platform boundaries and qualification record. Generating code still makes no request and establishes no live-proxy availability or geographic result.
