Proxy plans now up to 15% cheaper
View pricing

PHP (cURL, Guzzle)

Route PHP requests through a proxy using cURL or Guzzle. Add authentication and choose HTTP or SOCKS5 with copy-paste code.

Integrations6 min read

There are two standard ways to set up a PHP proxy: the native PHP cURL extension (CURLOPT_PROXY / CURLOPT_PROXYUSERPWD) and the Guzzle HTTP client (the proxy option). This page connects your PHP scraping, monitoring, or automation jobs to ColdProxy using the gateway gw-{service-id}.coldproxy.com on any port in 30000-34999, with working rotating and sticky-session examples plus the IP-whitelist alternative. The examples use gw-2312.coldproxy.com (replace 2312 with your service/package ID) and the USERNAME/PASSWORD from your client area. New to proxy auth? See IP whitelisting vs username/password.

Note

Residential IPv4 (GB Based) and Residential IPv6 activate instantly after payment clears. Residential IPv4 (Unmetered) and Datacenter IPv6 start automatic setup after payment clears; allow up to 10 minutes and connect as soon as setup completes. If a request fails, check your credentials and service status rather than assuming setup is the cause. See Activation and setup times.

Connection details

Connection details
Setting Value
Host gw-{service-id}.coldproxy.com — examples use gw-2312
Port Any in 30000-34999 (use 30000 in examples)
Protocols HTTP, HTTPS (TCP) and SOCKS5 (TCP/UDP), auto-detected
Auth USERNAME:PASSWORD, or IP whitelisting (up to 50 IPs)
String format gw-2312.coldproxy.com:PORT:USERNAME:PASSWORD

The equivalent embedded-credentials form is USERNAME:PASSWORD@gw-2312.coldproxy.com:PORT, which is what cURL and Guzzle expect.

PHP cURL — HTTP/HTTPS

The cURL extension ships with PHP, so no Composer dependency is needed. Set the gateway with CURLOPT_PROXY and the credentials with CURLOPT_PROXYUSERPWD. ColdProxy auto-detects the protocol, so the default proxy type (CURLPROXY_HTTP) works for both HTTP and HTTPS targets.

PHP
<?php
$ch = curl_init('https://api.vipv6proxy.com/api/checker/my-ip');

curl_setopt_array($ch, [
    CURLOPT_PROXY        => 'gw-2312.coldproxy.com',
    CURLOPT_PROXYPORT    => 30000,
    CURLOPT_PROXYUSERPWD => 'USERNAME:PASSWORD',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT      => 30,
]);

$response = curl_exec($ch);
if ($response === false) {
    fwrite(STDERR, 'cURL error: ' . curl_error($ch) . PHP_EOL);
} else {
    echo $response . PHP_EOL; // JSON: {"ip": "...", "version": ..., "country": "...", ...}
}
curl_close($ch);
Tip

Verify the exit IP and location of any request with the free Proxy Checker and What Is My IP tools before wiring the proxy into a larger job.

PHP cURL — SOCKS5

For SOCKS5, set CURLOPT_PROXYTYPE. Use CURLPROXY_SOCKS5_HOSTNAME (the equivalent of the socks5h scheme) so DNS is resolved on ColdProxy's side rather than locally; this keeps your real resolver out of the request and avoids DNS leaks. ColdProxy SOCKS5 supports both TCP and UDP.

PHP
<?php
$ch = curl_init('https://api.vipv6proxy.com/api/checker/my-ip');

curl_setopt_array($ch, [
    CURLOPT_PROXY        => 'gw-2312.coldproxy.com',
    CURLOPT_PROXYPORT    => 30000,
    CURLOPT_PROXYTYPE    => CURLPROXY_SOCKS5_HOSTNAME, // remote DNS
    CURLOPT_PROXYUSERPWD => 'USERNAME:PASSWORD',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT      => 30,
]);

echo curl_exec($ch) . PHP_EOL;
curl_close($ch);
Note

Use CURLPROXY_SOCKS5 instead if you want PHP to resolve DNS locally. For most data-collection workflows, remote DNS (CURLPROXY_SOCKS5_HOSTNAME) is the safer default. See SOCKS5 vs HTTPS proxies and TCP vs UDP proxies.

Rotating vs sticky sessions

ColdProxy encodes geo-targeting and session behavior in the username using a user-key-value-key-value... grammar (full reference: Username tag scheme). The username segments travel with HTTP Basic / SOCKS5 auth, so you select rotation or stickiness purely by changing the USERNAME placeholder above: no separate API call.

Rotating (new IP per request)

With no session tag, each request is assigned a fresh IP. Add geo tags to target a country, state, or city (here, a rotating US exit):

PHP
<?php
// Rotating US exit IP — confirm the exact country prefix in your client area
$proxyUser = 'user-country-us';

$ch = curl_init('https://api.vipv6proxy.com/api/checker/my-ip');
curl_setopt_array($ch, [
    CURLOPT_PROXY        => 'gw-2312.coldproxy.com',
    CURLOPT_PROXYPORT    => 30000,
    CURLOPT_PROXYUSERPWD => $proxyUser . ':PASSWORD',
    CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch) . PHP_EOL;
curl_close($ch);

Sticky (hold the same IP)

A sticky session needs both a session tag and a time (duration) tag together; supply one without the other and the connection rotates per request. The example below holds one US IP for 10 minutes:

PHP
<?php
// Sticky US IP for 10 minutes — same session ID + duration reuses the same exit IP
$proxyUser = 'user-country-us-session-481516-time-10m';

$ch = curl_init('https://api.vipv6proxy.com/api/checker/my-ip');
curl_setopt_array($ch, [
    CURLOPT_PROXY        => 'gw-2312.coldproxy.com',
    CURLOPT_PROXYPORT    => 30000,
    CURLOPT_PROXYUSERPWD => $proxyUser . ':PASSWORD',
    CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch) . PHP_EOL;
curl_close($ch);
Warning

The exact segment prefixes (for example the keys used for country, session, and time) are configured per product by ColdProxy; confirm the exact prefixes for your plan in your client area before deploying. Sticky duration limits: Residential IPv4 supports 5s to 24h; Residential IPv6 and Datacenter IPv6 support 5s up to FOREVER.

For the concepts behind these tags, see rotating and sticky proxies explained and geo-targeting with proxies.

Guzzle proxy

Guzzle reads the proxy request (or client) option. Embed credentials directly in the proxy URL as http://USERNAME:PASSWORD@host:port. The same rotating/sticky username tags apply; set them in the userinfo portion of the URL.

PHP
<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client();

// Sticky US IP for 10 minutes via username tags
$proxyUser = 'user-country-us-session-481516-time-10m';
$proxyUrl  = "http://{$proxyUser}:PASSWORD@gw-2312.coldproxy.com:30000";

$response = $client->get('https://api.vipv6proxy.com/api/checker/my-ip', [
    'proxy'   => $proxyUrl,
    'timeout' => 30,
]);

echo $response->getBody() . PHP_EOL;
Tip

If your USERNAME or PASSWORD contains URL-reserved characters such as @, :, or /, wrap each part in rawurlencode() before building the URL, otherwise Guzzle will misparse the userinfo. The username tags above use only -, letters, and digits, so they are URL-safe as-is.

You can also scope the proxy per scheme, which is useful if you want to bypass the proxy for some hosts:

PHP
<?php
$proxyUrl = "http://USERNAME:PASSWORD@gw-2312.coldproxy.com:30000";

$response = $client->get('https://example.com', [
    'proxy' => [
        'http'  => $proxyUrl,
        'https' => $proxyUrl,
        'no'    => ['localhost', '127.0.0.1'],
    ],
]);

Guzzle over SOCKS5

Guzzle's documented proxy option targets HTTP proxies. To run Guzzle through ColdProxy's SOCKS5 endpoint, pass the cURL SOCKS options directly through the curl request option (Guzzle uses the cURL handler by default):

PHP
<?php
$response = $client->get('https://api.vipv6proxy.com/api/checker/my-ip', [
    'curl' => [
        CURLOPT_PROXY        => 'gw-2312.coldproxy.com',
        CURLOPT_PROXYPORT    => 30000,
        CURLOPT_PROXYTYPE    => CURLPROXY_SOCKS5_HOSTNAME,
        CURLOPT_PROXYUSERPWD => 'USERNAME:PASSWORD',
    ],
]);

echo $response->getBody() . PHP_EOL;

IP whitelist alternative

Instead of sending USERNAME:PASSWORD, you can authorize your server's public IP (up to 50 addresses) in the client area. Whitelisted requests need no credentials; drop CURLOPT_PROXYUSERPWD (cURL) or the userinfo in the Guzzle URL:

PHP
<?php
// IP-authenticated request — no username/password
$ch = curl_init('https://api.vipv6proxy.com/api/checker/my-ip');
curl_setopt_array($ch, [
    CURLOPT_PROXY     => 'gw-2312.coldproxy.com',
    CURLOPT_PROXYPORT => 30000,
    CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch) . PHP_EOL;
curl_close($ch);
Note

IP authentication and username/password can both be active at once. With IP-auth and no username tags, the geo defaults to Worldwide. To bind geo-targeting and sticky behavior to specific ports without per-request username tags, configure SuperPorts (port-range rules) in your client area (for example, ports 30000-31000 fixed to US with a 10-minute sticky window).

Verify and troubleshoot

  • Confirm reachability, exit IP, and location with the Proxy Checker and What Is My IP tools.
  • A 407 from cURL/Guzzle means authentication failed. Recheck USERNAME:PASSWORD and the authentication mode. For Residential IPv4 (Unmetered) and Datacenter IPv6, also check whether automatic setup has completed. See Common errors & fixes and Activation and setup times.
  • Using an IPv6 plan? Many sites are IPv4-only (no AAAA DNS record) and will fail over IPv6. Check your target with the IPv6 Checker before buying; see IPv6 reachability for the confirmed-platform list and CDN-aware routing details.

Next steps

Need a tailored proxy plan for a large project?

Need a different speed or traffic allowance? Contact us through the channels on our website so we can assess whether a custom plan is possible.

Contact Our Sales TeamTelegram & ticket support · English and Arabic