- Host
- gw.prokso.com
- Port
- 823 HTTP · 824 SOCKS5 - new IP per request · 10000–20000 sticky session, HTTP(S) and SOCKS5
- Username and password
- in your dashboard, on the plan page
Your dashboard generates ready-made lines in the format you need: choose the country, IP type and protocol.
- The proxy option in the Client constructor: a string with the username or an array by scheme with the no key
- SOCKS5 only through the cURL handler (socks5:// or socks5h://)
- timeout and connect_timeout default to 0 in Guzzle 7 - set them explicitly
Video transcript
Prokso proxies in Guzzle.
First, get your proxy details from the dashboard: host, port, username and password. They are on the plan page, in the Access block.
In Guzzle, set the proxy address in the proxy option when you create the client.
Run the example: the output should show the proxy IP, not yours. On port 823, every run gets a new address.
The full guide with examples is on the Prokso website.
In Guzzle, a proxy is a regular request option, proxy. You can pass it to the client constructor, and then it applies to all requests, or set it separately for a single request. Under the hood it is handled by a handler: with cURL both HTTP and SOCKS5 work, while the PHP stream handler can only do HTTP proxies. The examples below are for Guzzle 7, and the differences in version 8 are collected at the end.
Step 1. Build the line for the proxy option
Guzzle accepts the proxy address together with the scheme, username and password: http://username:password@gw.prokso.com:823. The dashboard generator gives you this line in the format with the protocol. You can also pass an array, where the key is the site's scheme (http or https) and the value is its own proxy for it.
Prokso ports: 823 is HTTP with a new IP for every request, 824 is rotating SOCKS5, 10000-20000 is a sticky IP for 1-120 minutes for both protocols. The username sets the country.
A username and password with @, : or # break the URL. cURL decodes the username and password before using them, so encode them with rawurlencode() - see the example in step 4.

Step 2. Install Guzzle and check ext-curl
Guzzle is installed with Composer: composer require guzzlehttp/guzzle. Version 7 runs on PHP 7.2.5 and newer.
Check that PHP has the cURL extension (php -m should list curl). Without it Guzzle will use the stream handler, and SOCKS5 will not work.
Step 3. The proxy in the client constructor
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client([
'proxy' => 'http://USERNAME:PASSWORD@gw.prokso.com:823',
'connect_timeout' => 10,
'timeout' => 30,
]);
echo $client->get('https://api.ipify.org')->getBody(), PHP_EOL;Guzzle applies all options passed to the constructor as defaults for every request of this client. That is why a client with a proxy is created once and reused. For a request with a different proxy, you can override the proxy option in the get call itself.
In Guzzle 7, connect_timeout and timeout default to 0, which means waiting indefinitely. With a proxy that does not respond, the script would hang without them, so both are set explicitly.
Step 4. Separate proxies for http and https, the no exclusion
$user = rawurlencode('USERNAME');
$pass = rawurlencode('PASSWORD');
$client = new GuzzleHttp\Client([
'proxy' => [
'http' => "http://$user:$pass@gw.prokso.com:823",
'https' => "http://$user:$pass@gw.prokso.com:10001",
'no' => ['localhost', '.internal.example'],
],
]);The no key is a list of hosts that go direct. If you do not set it, Guzzle fills it in from the NO_PROXY environment variable. In the example, https sites go through a sticky port and http through a rotating port.
Step 5. Run the script and look at the output
Run php proxy.php. The script prints one line - the IP the site sees your request from. This is the proxy's address, not your server's. A second run on port 823 shows a different IP, on a sticky port the same one until the hold time ends.
If the script ends with an exception, check the line separately in the proxy checker: this will show where the problem is - in the plan details or in the code.

SOCKS5 through cURL
$client = new GuzzleHttp\Client([
'proxy' => 'socks5h://USERNAME:PASSWORD@gw.prokso.com:824', // cURL
'timeout' => 30,
]);The Guzzle 7 stream handler only really handles proxies with the http scheme, so SOCKS5 works only with the cURL handler. The scheme is parsed by libcurl: socks5:// is SOCKS5, socks5h:// is SOCKS5 where site names are resolved by the proxy itself. For Prokso either one works on port 824 or on a sticky port.
Guzzle timeouts and exceptions
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\ServerException;
try {
$res = $client->get('https://api.ipify.org');
} catch (ConnectException $e) {
echo 'proxy/network: ', $e->getMessage(), PHP_EOL;
} catch (ClientException $e) {
echo '4xx: ', $e->getResponse()->getStatusCode(), PHP_EOL;
} catch (ServerException $e) {
echo '5xx: ', $e->getResponse()->getStatusCode(), PHP_EOL;
}- ConnectException - a network error: could not connect to the proxy or set up the tunnel. Check the port and scheme, and if access is refused, the username, password and remaining traffic (code 407).
- ClientException - a 4xx response. With a proxy this is usually 403 or 429 from the site; with
'http_errors' => falseGuzzle simply returns the response instead of an exception. - ServerException - a 5xx response from the site.
- RequestException - the common parent class for request errors, if you need one handler for everything.
A request pool with a concurrency limit
use GuzzleHttp\Pool;
use GuzzleHttp\Psr7\Request;
$requests = function (array $urls) {
foreach ($urls as $url) {
yield new Request('GET', $url);
}
};
$pool = new Pool($client, $requests($urls), [
'concurrency' => 10, // no more than 10 requests at once
'fulfilled' => function ($response, $index) {
echo $index, ': ', $response->getStatusCode(), PHP_EOL;
},
'rejected' => function ($reason, $index) {
echo $index, ': request failed - ', $reason->getMessage(), PHP_EOL;
},
]);
$pool->promise()->wait();Pool sends requests in parallel, but no more than concurrency at a time. On port 823 every request from the pool gets its own address. The plan limit is up to 1000 concurrent connections, so concurrency together with other scripts should stay below it. For simpler cases there is getAsync() with Promise\Utils::settle(), which waits for all requests even if some of them failed.
What changed in Guzzle 8
- The
proxyoption accepts only strings, other values give anInvalidArgumentException. - The stream handler refuses schemes it cannot handle, including SOCKS, so cURL is required for port 824.
- cURL handlers wait 60 seconds for a connection by default instead of 300 in libcurl.
ClientExceptionandServerExceptionnow inherit fromResponseException.- The uppercase
HTTP_PROXYvariable is no longer read at all.
The examples on this page work in both versions if the proxy is passed as a string and SOCKS5 goes through cURL.
If the proxy does not work
FAQ
Why does Guzzle ignore the HTTP_PROXY variable?
Because of the httpoxy vulnerability, Guzzle 7 reads HTTP_PROXY only when run from the command line (CLI), and not in a web request. Guzzle 8 does not read this variable at all. Pass the proxy with the proxy option.
Does SOCKS5 work in Guzzle without cURL?
No. The stream handler can only do HTTP proxies. Install the curl extension for PHP - Guzzle will pick the cURL handler on its own.
How do I set a proxy for just one request?
Pass 'proxy' => '…' in the parameters of a specific get or request call: request options override the client's default options.
Why does the script hang without a response?
In Guzzle 7, timeout and connect_timeout default to zero, which means no limit. Set both in the client constructor.
How many parallel requests should I set in Pool?
Start with 10 and increase while the site responds without 429. In total a plan allows up to 1000 concurrent connections, counting all programs that use it.
Was this guide helpful?
Thanks for your feedback!
Sorry about that. Tell us which step you got stuck on and we will help.