HttpRequestException with StatusCode 407
Check Whether Credentials is set on the WebProxy and LOGIN and PASSWORD match My assets.
Fix Add or correct the credential and run again.
Updated
curl -x http://USER:PASS@HOST:PORT https://ipinfo.io/json
A short program that sends a request through a proxy with a username and password, and what changes for SOCKS5 or a default proxy.
| Item | Reach | Login |
|---|---|---|
| Handler.Proxy (WebProxy) | The one HttpClient built from that handler; overrides the default | Set on the WebProxy.Credentials property |
| HttpClient.DefaultProxy | Every HttpClient that has no proxy of its own | Not set in code here; it is read from the environment or system settings |
| HTTP_PROXY / HTTPS_PROXY | Feed the default proxy on Windows and Linux | May be written in the URL as http://LOGIN:PASSWORD@HOST:2222; the URL must start with http, not https |
Microsoft Learn pages read on 20 November 2026.
using System.Net;
var proxy = new WebProxy(new Uri("http://HOST:2222"))
{
Credentials = new NetworkCredential("LOGIN", "PASSWORD")
};
var handler = new SocketsHttpHandler
{
Proxy = proxy,
UseProxy = true
};
// Create one HttpClient and reuse it for the whole life of the app
using var client = new HttpClient(handler)
{
Timeout = TimeSpan.FromSeconds(30)
};
var json = await client.GetStringAsync("https://ipinfo.io/json");
Console.WriteLine(json);Example for .NET 8 or 9 (top-level statements). Replace HOST, LOGIN and PASSWORD with the values in My assets. Not compiled here.
using System.Net;
// Same code as above, only the proxy line changes (SOCKS5 port 3333).
// Use the Uri overload of WebProxy.
var proxy = new WebProxy(new Uri("socks5://HOST:3333"))
{
Credentials = new NetworkCredential("LOGIN", "PASSWORD")
};Example. .NET 6 and later accept the socks5 scheme. The .NET blog does not state that a SOCKS username and password are supported, so test it; if it fails with the right login, use the HTTP proxy on port 2222.
Get an IP and copy HOST, port, LOGIN and PASSWORD from My assets. HTTP goes with port 2222, SOCKS5 with 3333.
Paste the program above into a console project, replace the placeholders and run it.
Expected result JSON from ipinfo.io whose ip field is the proxy's address, not yours.
Move the handler and client creation to one place (a static field or a dependency-injection singleton) so the whole app reuses one HttpClient.
Catch HttpRequestException and read StatusCode; catch TaskCanceledException for a timeout and look at its inner exception.
Microsoft recommends reusing HttpClient for the life of the app. That matters for a rotating proxy: Proxy302 rotating lines give a new IP to each new connection, and a reused client keeps connections alive, so several requests can leave from the same IP. If you need a new IP per request, create a new connection each time, for example with a separate handler for that job; if you need to keep one IP, use a static IP or a session on the line.
A static or datacenter IP bought per IP does not rotate during its lease, which suits one long-running client.
Check Whether Credentials is set on the WebProxy and LOGIN and PASSWORD match My assets.
Fix Add or correct the credential and run again.
Check Whether the inner exception is a TimeoutException, and whether HOST and port are right and not blocked by your network.
Fix Test the same proxy with curl from the same machine; raise Timeout only if curl is slow too.
Check That UseProxy is true, the handler is the one passed to HttpClient, and the WebProxy was built with an address (the empty constructor uses no proxy).
Fix Fix the wiring and print the ip field again.
Check For an HTTP proxy the address starts with http://; Microsoft notes that proxy URLs in the environment variables must start with http.
Fix Change the scheme to http (or socks5 for SOCKS5).
A datacenter IP costs US$0.25 for 1 day and US$3.99 for 30 days, and a static ISP IP US$0.50 for 1 day and US$7.99 for 30 days, the same in every country; an order takes 1 to 100 IPs. HTTP uses port 2222 and SOCKS5 port 3333. Rotating residential starts at US$1.50 per GB on the Budget line. There is no free trial.
Build a WebProxy with the address, set its Credentials, put it in the handler's Proxy property and create the HttpClient from that handler.
Yes, from .NET 6, with a socks5:// address. The .NET blog does not say that a SOCKS username and password are supported, so test them or use HTTP on port 2222.
No. Microsoft recommends reusing instances during the application lifecycle.
For the HTTP_PROXY and HTTPS_PROXY variables yes, as http://LOGIN:PASSWORD@HOST:2222. In code, set WebProxy.Credentials.
US$0.25 for 1 day and US$3.99 for 30 days, the same in every country.
Setup guides Proxy302 publishes on GitHub on the same topic:
Official documentation · Confirmed on:
Read on 20 November 2026: an HTTP proxy is set either by the static HttpClient.DefaultProxy (read from environment variables or system settings; on Linux with no variables it bypasses all addresses) or by the Proxy property of the handler, which overrides it; the HTTP_PROXY and HTTPS_PROXY URL may carry a username and password and must start with http, not https; the recommended approach is to reuse HttpClient instances during the application lifecycle; HttpClient.Timeout expiry raises TaskCanceledException with a TimeoutException inside; HttpRequestException carries StatusCode.
Official documentation · Confirmed on:
Read on 20 November 2026: WebProxy contains the proxy settings HttpClient uses; it has an Address, a BypassList and a Credentials property for proxy authentication; the example builds an HttpClient from an HttpClientHandler whose Proxy is a WebProxy; a WebProxy built with the empty constructor has a null Address and uses no proxy.
Official documentation · Confirmed on:
Read on 20 November 2026: Proxy gets or sets the custom proxy when UseProxy is true.
Official documentation · Confirmed on:
Read on 20 November 2026: .NET 6 added SOCKS4, SOCKS4a and SOCKS5 proxy support for HttpClient, enabled by using the socks scheme in the proxy definition; the post's example uses SocketsHttpHandler with a WebProxy for socks5://127.0.0.1:9050, and a footnote says the string constructor overload works only with HTTP proxies (fixed in .NET 7). The post does not say whether a SOCKS username and password are supported.
Product observation · Confirmed on:
Product facts file of the site, checked 20 November 2026 against the console and the price table: per-IP lease prices in US$ (1 PTC = US$1) for 1 to 90 days, HTTP port 2222 and SOCKS5 port 3333, quantity limit, no free trial, optional auto-renew.
Create an account, top up once, then pick rotating residential, static ISP or datacenter IPs and have one running in your browser within minutes.