- 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.
- Host gw.prokso.com, ports 823 (HTTP), 824 (SOCKS5), 10000–20000 (sticky sessions, HTTP or SOCKS5)
- The username and password are in your dashboard on the plan page
- Check the IP in the response of the proxied request itself: the My IP page in a browser does not test your script
A step-by-step guide to connecting Prokso proxies in Java. It takes a few minutes.
Step 1. Get the proxy details from your dashboard
Open your plan and copy the host gw.prokso.com, port, username and password. Port 823 is HTTP and 824 is SOCKS5 (both give a new IP for every request); ports 10000–20000 keep one IP (sticky session) for up to 120 minutes and work as both HTTP and SOCKS5 (each port is a separate address). Set the country in the username: username__cr.ua.
Step 2. Use Java 11 or later
The example uses the built-in java.net.http.HttpClient, available in the JDK since version 11. No third-party libraries are needed.
Step 3. Enable Basic auth for the tunnel
By default the JDK doesn't send the proxy username and password when it opens an https website through a tunnel, and the request fails with a 407 error. The jdk.http.auth.tunneling.disabledSchemes system property set to an empty value turns it on. Set it at the very start of the program, as in the example, or with the launch flag -Djdk.http.auth.tunneling.disabledSchemes=.
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.ProxySelector;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Main {
public static void main(String[] args) throws Exception {
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
HttpClient client = HttpClient.newBuilder()
.proxy(ProxySelector.of(new InetSocketAddress("gw.prokso.com", 823)))
.authenticator(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("USERNAME", "PASSWORD".toCharArray());
}
})
.connectTimeout(Duration.ofSeconds(30))
.build();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.ipify.org?format=json")).build();
System.out.println(client.send(request, HttpResponse.BodyHandlers.ofString()).body());
}
}Step 4. Give the client the proxy and credentials
ProxySelector.of sets the proxy address and an Authenticator supplies the username and password. HttpClient answers the proxy's authentication challenge on its own. Create the client once and reuse it for all requests.
Step 5. SOCKS5 and a sticky IP
HttpClient only works with HTTP proxies. For SOCKS5 you need the older HttpURLConnection with a java.net.Proxy of type SOCKS on port 824 and the same Authenticator installed with Authenticator.setDefault. For a series of requests from one IP, switch to a sticky port from 10000-20000.
Step 6. If the connection fails
Check the host gw.prokso.com, the port and the scheme: HTTP on 823, SOCKS5 on 824, either one on ports 10000-20000. A 407 error means a wrong username or password, or the plan has run out of traffic: check the balance on the plan page in your dashboard. A timeout most often means a typo in the port or a client expecting a different protocol. If you use the IP whitelist, make sure the external address of the exact machine running the code is on the list.
Step 7. Check the output
Run the example: the program calls https://api.ipify.org and prints the IP the website sees. It should be the proxy's address, not yours. A 407 error means a wrong username or password, or the plan has run out of traffic. The My IP page in your browser won't help here: the browser goes direct.
FAQ
Why a 407 error when the username is correct?
Most often the <code>jdk.http.auth.tunneling.disabledSchemes</code> property isn't set, so the JDK doesn't send credentials for https websites. Set it before creating the client or with a <code>-D</code> flag at launch.
Can I skip the username and password?
Yes. Turn on the IP whitelist in the plan and add the address of the server the program runs on. Then you need neither the <code>Authenticator</code> nor the system property.
Which port should I use?
Port 823 (HTTP) or 824 (SOCKS5) gives a new IP on every request, which suits data collection. A port from 10000-20000 keeps one IP for up to 120 minutes, for sessions where you sign in to an account. A plan allows up to 1,000 concurrent connections.
How do I choose a country?
The country is part of the proxy username. Generate a line for the country you need in the dashboard and use its username in the code; the rest of the address stays the same.
What if some requests fail?
When collecting data, some addresses can be slow or unavailable. Add a few retries with a pause to your code: on port 823 or 824 every retry goes out from a new address.