Share via

HttpClient.DefaultProxy Property


Gets or sets the global HTTP proxy.

 static property System::Net::IWebProxy ^ DefaultProxy { System::Net::IWebProxy ^ get(); void set(System::Net::IWebProxy ^ value); };
public static System.Net.IWebProxy DefaultProxy { get; set; }
static member DefaultProxy : System.Net.IWebProxy with get, set
Public Shared Property DefaultProxy As IWebProxy

Property Value

A proxy used by every HTTP request.


The value passed cannot be null.


This static property determines the default proxy that all HttpClient instances use if no proxy is set explicitly in the HttpMessageHandler passed through its constructor.

The default instance returned by this property will initialize following a different set of rules depending on your platform:

  • For Windows: Reads proxy configuration from environment variables or, if those are not defined, from the user's proxy settings.

  • For macOS: Reads proxy configuration from environment variables or, if those are not defined, from the system's proxy settings.

  • For Linux: Reads proxy configuration from environment variables or, in case those are not defined, this property initializes a non-configured instance that bypasses all addresses.

The environment variables used for DefaultProxy initialization on Windows and Unix-based platforms are:

  • HTTP_PROXY: the proxy server used on HTTP requests.
  • HTTPS_PROXY: the proxy server used on HTTPS requests.
  • ALL_PROXY: the proxy server used on HTTP and/or HTTPS requests in case HTTP_PROXY and/or HTTPS_PROXY are not defined.
  • NO_PROXY: a comma-separated list of hostnames that should be excluded from proxying. Asterisks are not supported for wildcards; use a leading dot in case you want to match a subdomain. Examples: NO_PROXY=.example.com (with leading dot) will match www.example.com, but will not match example.com. NO_PROXY=example.com (without leading dot) will not match www.example.com. This behavior might be revisited in the future to match other ecosystems better.

On systems where environment variables are case-sensitive, the variable names may be all lowercase or all uppercase. The lowercase names are checked first.

The proxy server may be a hostname or IP address, optionally followed by a colon and port number, or it may be an http URL, optionally including a username and password for proxy authentication. The URL must be start with http, not https, and cannot include any text after the hostname, IP, or port.

Applies to