Proxy setup in C# (.NET)

Proxies in C# and .NET: HttpClientHandler with WebProxy, credentials via NetworkCredential, SOCKS5 since .NET 6 and one HttpClient for the whole app.

Updated · Prokso editorial team

Connection details
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.

Key takeaways
  • 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 C# (.NET). 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. Create a console project

You need .NET 6 or later: dotnet new console. HttpClient, WebProxy and NetworkCredential are built in, so no NuGet packages are required.

using System.Net;

var handler = new HttpClientHandler
{
    Proxy = new WebProxy("http://gw.prokso.com:823")
    {
        Credentials = new NetworkCredential("USERNAME", "PASSWORD")
    },
    UseProxy = true
};

using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(30) };
Console.WriteLine(await client.GetStringAsync("https://api.ipify.org?format=json"));

Step 3. Set up a handler with the proxy

Create an HttpClientHandler, give it a WebProxy with the address http://gw.prokso.com:823, and pass the username and password as a NetworkCredential in the Credentials property. Put the code below into Program.cs.

Step 4. One HttpClient for the whole app

Create the client once and reuse it for all requests so connections to the proxy are reused. The proxy belongs to the handler, so a different port or country needs its own handler and its own client.

Step 5. SOCKS5 and a sticky IP

Since .NET 6, WebProxy accepts the address socks5://gw.prokso.com:824, and the username and password still come from Credentials. For a series of requests from one IP, use 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 is the proxy ignored?

Check that <code>UseProxy = true</code> is set and that the client was created with this exact handler. Without a handler, <code>HttpClient</code> uses the system proxy settings.

Can I skip the username and password?

Yes. Turn on the IP whitelist in the plan and add the address of the machine the program runs on. Then you can leave <code>Credentials</code> unset.

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.