PHP

How to Use SocksNode Residential Proxies with PHP

Quick answer

To use SocksNode residential proxies in PHP, set CURLOPT_PROXY to global.socksnode.com:9000 and CURLOPT_PROXYUSERPWD to your username token and password. Use port 9000 for rotating IPs or 10000 with a session token for sticky IPs, switch to CURLPROXY_SOCKS5_HOSTNAME for SOCKS5, and set geo targeting in the username.

Before you start

SocksNode offers residential proxies across 195+ countries over HTTP, HTTPS, and SOCKS5 with username/password auth. Generate credentials for free in the dashboard proxy generator; only routed traffic consumes your prepaid bandwidth (from 5 GB for $4.50, non-expiring on flexible plans).

PHP's cURL extension covers both HTTP and SOCKS5, and Guzzle can wrap the same settings if you prefer a higher-level client.

PHP 8.0+ with the curl extension enabled
A SocksNode account with prepaid bandwidth
A username/password from /dashboard/generator
Your chosen protocol and port
Your target country token

Configure the proxy in PHP

Set proxy options on a cURL handle:

For SOCKS5, add curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME) and use port 11000, which resolves DNS through the proxy. Change the country token to target any of 195+ countries.

<?php
$ch = curl_init('https://api.ipify.org');
curl_setopt($ch, CURLOPT_PROXY, 'global.socksnode.com:9000');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'USERNAME-country-us:PASSWORD');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

Rotating vs sticky sessions

Rotating sessions give a new residential IP per request: HTTP port 9000 or SOCKS5 port 11000. Good for spreading requests across many exits.

Sticky sessions hold one IP from 1 minute up to 24 hours: HTTP port 10000 or SOCKS5 port 12000. Set CURLOPT_PROXYUSERPWD to a token like USERNAME-country-us-session-cron1-lifetime-30 to keep one IP across a job.

Geo targeting and compliance

Targeting is set through username tokens: country across 195+ countries, US state and city, or ASN/ISP within a country. Only the username in CURLOPT_PROXYUSERPWD changes between regions.

Collect data lawfully, respect each site's terms of service, and stay within applicable law and reasonable request rates.

See also

Frequently asked questions

How do I pass credentials in PHP cURL?

Set CURLOPT_PROXYUSERPWD to 'USERNAME-country-us:PASSWORD'. Keep the host and port in CURLOPT_PROXY, for example global.socksnode.com:9000.

How do I use SOCKS5 in PHP?

Set CURLOPT_PROXYTYPE to CURLPROXY_SOCKS5_HOSTNAME and point CURLOPT_PROXY at port 11000 (rotating) or 12000 (sticky) so DNS resolves on the proxy.

How do I keep the same IP across a job?

Use port 10000 with a session token like USERNAME-country-us-session-cron1-lifetime-30 so the residential IP stays fixed for up to 24 hours.

Can I target a country or US city?

Yes. Add country, and for the US state and city, tokens to the username, across 195+ supported countries plus ASN/ISP options.

Does generating credentials cost anything?

No. Generating credentials is free; only the traffic your requests route through the proxy consumes prepaid bandwidth.

Related posts

All posts

Get started.

Create an account, generate a credential, connect. The API is the same one the dashboard uses.