Not set by default. When not set, HTTPS connections are made directly, without a proxy (unless java.net.useSystemProxies is enabled).
https.proxyHostThe 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.proxyHostdoes not apply to HTTP URLsPlain
httpURLs use thehttp.proxyHostandhttp.proxyPortsystem properties. If you need to proxy both HTTP and HTTPS traffic, you must set both sets of properties. There is no separatehttps.nonProxyHostsproperty, the HTTPS protocol handler useshttp.nonProxyHosts.
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.
https.proxyPort - the port number of the HTTPS proxy server, default 443.http.proxyHost and http.proxyPort - the proxy server used for HTTP connections.http.nonProxyHosts - a | separated list of hosts that should be accessed directly, bypassing the proxy. Used for both HTTP and HTTPS connections.java.net.useSystemProxies - use the operating system's proxy settings.Here are some other networking Java system properties:
com.sun.net.ssl.checkRevocationcom.sun.security.enableCRLDPhttp.agenthttp.keepAlivehttp.maxConnectionshttp.nonProxyHostshttp.proxyHosthttp.proxyPorthttps.protocolshttps.proxyPortjava.net.preferIPv4Stackjava.net.preferIPv6Addressesjava.net.useSystemProxiesjavax.net.debugjavax.net.ssl.trustStorejdk.http.maxHeaderSizejdk.net.hosts.filejdk.tls.client.protocolsjdk.tls.server.newSessionTicketCountjdk.crypto.disabledAlgorithmsjdk.tls.disabledAlgorithmsnetworkaddress.cache.negative.ttlnetworkaddress.cache.ttlocsp.enablesun.net.client.defaultConnectTimeoutsun.net.client.defaultReadTimeoutsun.net.inetaddr.ttlJava has supported the https.proxyHost system property since at least Java 1.4.
https.proxyHost on StartupYou 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
https.proxyHost at RuntimeYou 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
setPropertymay 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");
}