The default value excludes the common variations of the loopback address, so that connections to the local machine are not sent through the proxy. Current OpenJDK source also includes 0.0.0.0 and [::0] in the default list.
http.nonProxyHostsWhen a proxy server has been configured with the http.proxyHost or https.proxyHost system properties, all connections for that protocol are sent through the proxy. The http.nonProxyHosts system property lets you list hosts that should be reached directly instead, typically internal hosts.
There is no https.nonProxyHosts property: the HTTPS protocol handler uses the same http.nonProxyHosts list as the HTTP protocol handler. FTP uses its own ftp.nonProxyHosts property.
| character, for example: localhost|host.example.com* wildcard character, for example *.example.com matches every host in the example.com domain, and 192.168.* matches IP addresses starting with 192.168.10.* will only bypass the proxy for URLs that use an IP address like http://10.1.2.3/, not for host names that happen to resolve to a 10.x.x.x address.In current OpenJDK versions, when you set http.nonProxyHosts to a non-empty value the default loopback patterns are appended to your list, so localhost will still bypass the proxy. Setting the property to an empty string removes all exclusions, including the loopback defaults.
Tip: Quote the value on the command line
The
|character is the pipe operator in most shells, so be sure to wrap the value in quotes when passing it on the command line.
java -Dhttp.proxyHost=proxy.example.com -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxy.example.com -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts="localhost|*.example.com|192.168.*" -jar app.jar
In this example HTTP and HTTPS connections go through proxy.example.com:8080, except connections to localhost, any host in the example.com domain, or any 192.168.* IP address.
http.proxyHost and http.proxyPort - the proxy server used for HTTP connections.https.proxyHost and https.proxyPort - the proxy server used for HTTPS connections.ftp.nonProxyHosts - the equivalent list of hosts that bypass the FTP proxy.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.proxyHosthttp.proxyPorthttps.protocolshttps.proxyHosthttps.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 http.nonProxyHosts system property since at least Java 1.4.
http.nonProxyHosts on StartupYou can set the http.nonProxyHosts java system property during startup of the java runtime using the -D command line argument:
java -Dhttp.nonProxyHosts=localhost|*.example.com MyAppMain
You may also be able to specify http.nonProxyHosts via the JAVA_TOOL_OPTIONS environment variable:
JAVA_TOOL_OPTIONS=-Dhttp.nonProxyHosts=localhost|*.example.com
http.nonProxyHosts at RuntimeYou can set http.nonProxyHosts at runtime with the following Java code:
System.setProperty("http.nonProxyHosts", "localhost|*.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 http.nonProxyHosts system property may be cached within an internal private static variable of the implementing class.
To read the value of http.nonProxyHosts at runtime, you can use this Java code:
String propertyValue = System.getProperty("http.nonProxyHosts");
if (propertyValue != null) {
System.out.println("http.nonProxyHosts = " + propertyValue);
} else {
System.out.println("http.nonProxyHosts was null");
}