How to Set Up Proxies in PHP cURL
Route PHP cURL traffic through an authenticated proxy in a few lines. Copy the code below and swap in your credentials.
Quick answer
Set the proxy in the format host:port + CURLOPT_PROXYUSERPWD user:pass and send your PHP cURL request through it. Full code below.
PHP cURL proxy example
<?php
$ch = curl_init("https://httpbin.org/ip");
curl_setopt($ch, CURLOPT_PROXY, "host:port");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "user:pass");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;PHP's cURL binding mirrors the command-line tool: set CURLOPT_PROXY to the host:port and CURLOPT_PROXYUSERPWD to the credentials rather than jamming them into one string. Add CURLOPT_PROXYTYPE = CURLPROXY_SOCKS5_HOSTNAME when you need SOCKS5 with remote DNS. Reuse the curl handle across requests to the same rotating gateway to benefit from keep-alive, and always check curl_error() so a dead proxy surfaces instead of returning silently empty output.
Rotating proxies
PHP cURL works cleanly with rotating backconnect endpoints — point it at a single gateway host and the provider rotates the exit IP for you.
Best proxies to use with PHP cURL
Cheapest-Proxies.com EDITOR'S CHOICE
4.9Best overall value across every proxy type and use case · flexible pay-as-you-go plans
Visit Cheapest-Proxies.comBright Data
4.6Enterprise-grade proxy and web data platform · from ~$8-9/GB (residential, volume-dependent)
Read Bright Data reviewOxylabs
4.6Premium enterprise proxies and scraper APIs · from ~$8/GB (residential, volume-dependent)
Read Oxylabs reviewSmartproxy
4.5User-friendly proxies with excellent price-to-performance · from ~$3.50-7/GB (residential)
Read Smartproxy reviewOur #1 pick is a sponsored partner. Remaining providers are ranked editorially by rating and value.
Frequently Asked Questions
Does PHP cURL support authenticated proxies?
Yes. Provide the username and password (as a URL or separate fields) and PHP cURL handles the auth handshake.
What proxies work best with PHP cURL?
Residential or rotating proxies from a reliable provider give the best success rate for PHP projects.
Can PHP cURL rotate proxies automatically?
Yes — point it at a rotating backconnect endpoint and the provider rotates IPs for you.
How do I add a proxy in PHP cURL?
Supply the proxy as host:port + CURLOPT_PROXYUSERPWD user:pass and pass it to PHP cURL as shown in the code above.
Related Guides
Best proxies for PHP cURL
For most buyers this provider hits the best balance of price and reliability — check current pricing.
Visit Cheapest-Proxies.com