Java System Properties
Quick Reference Guide


https.proxyHost Java System Property

The https.proxyHost java system property specifies the hostname or IP address of the proxy server used for HTTPS connections.

Default Value

Not set by default. When not set, HTTPS connections are made directly, without a proxy (unless java.net.useSystemProxies is enabled).

Overview of https.proxyHost

The https.proxyHost system property sets the hostname, or address, of the proxy server that the https protocol handler should use. It is typically used together with the https.proxyPort system property, which defaults to 443 when not specified.

The property is used by the default ProxySelector, so it applies to connections made with java.net.URL / HttpsURLConnection, and also to the java.net.http.HttpClient (Java 11+) when no explicit proxy selector has been set on the client builder.

HTTPS requests are sent through the proxy using an HTTP CONNECT tunnel, so the TLS connection is still established end-to-end between the client and the destination server.

Note: https.proxyHost does not apply to HTTP URLs

Plain http URLs use the http.proxyHost and http.proxyPort system properties. If you need to proxy both HTTP and HTTPS traffic, you must set both sets of properties. There is no separate https.nonProxyHosts property, the HTTPS protocol handler uses http.nonProxyHosts.

Example

java -Dhttps.proxyHost=proxy.example.com -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts="localhost|*.example.com" -jar app.jar

In this example all HTTPS connections will go through the proxy server at proxy.example.com on port 8080, except for connections to localhost or any host in the example.com domain.

Related Properties

Other Networking System Properties

Here are some other networking Java system properties:

References

Supported Since

Java has supported the https.proxyHost system property since at least Java 1.4.

Setting https.proxyHost on Startup

You can set the https.proxyHost java system property during startup of the java runtime using the -D command line argument:

java -Dhttps.proxyHost=proxy.example.com MyAppMain

You may also be able to specify https.proxyHost via the JAVA_TOOL_OPTIONS environment variable:

JAVA_TOOL_OPTIONS=-Dhttps.proxyHost=proxy.example.com

Setting / Reading https.proxyHost at Runtime

You can set https.proxyHost at runtime with the following Java code:

System.setProperty("https.proxyHost", "proxy.example.com");

WARNING: Depending on the property and JVM version using setProperty may or may not work if the JDK Java class that uses this variable has already been loaded. The value of the https.proxyHost system property may be cached within an internal private static variable of the implementing class.

To read the value of https.proxyHost at runtime, you can use this Java code:

String propertyValue = System.getProperty("https.proxyHost");
if (propertyValue != null) {
    System.out.println("https.proxyHost = " + propertyValue);
} else {
    System.out.println("https.proxyHost was null");
}