Gradle proxy settings: configure an HTTP and HTTPS proxy
Codemia Knowledge Hub ·
To make Gradle use a proxy, add systemProp.http.* and systemProp.https.* entries to a gradle.properties file. Put them in the Gradle user home directory to apply them to every build, or in a project's root directory to apply them to that project only. Without this, Gradle cannot fetch dependencies and plugins from remote repositories on networks where all traffic must pass through a proxy server.
Setting the proxy for all projects
Edit gradle.properties in the Gradle user home directory: ~/.gradle/gradle.properties on Unix-like systems or C:\Users\<user>\.gradle\gradle.properties on Windows.
The user and password lines are optional. nonProxyHosts lists the hosts Gradle should reach directly, separated by |. Keep comments on their own lines: in a .properties file, a # after a value becomes part of the value.
Setting the proxy for one project
Put the same entries in the gradle.properties file in that project's root directory.
Example with authentication
For a proxy with these details:
- Proxy host:
proxy.example.com - Proxy port:
8080 - Proxy user:
user123 - Proxy password:
pass123 - Non-proxy hosts:
localhost,127.0.0.1and*.example.org
the configuration is:
The user and password entries are only needed when the proxy requires authentication. Keep these credentials out of files that are shared or committed to version control; prefer the per-user ~/.gradle/gradle.properties, GRADLE_OPTS, or another secure store.
Proxy settings reference
| Configuration item | Description | Example value |
| Proxy host | Hostname or IP address of the proxy server | proxy.example.com |
| Proxy port | Port number of the proxy server | 8080 |
| Proxy user | Optional; username for proxy authentication | user123 |
| Proxy password | Optional; password for proxy authentication | pass123 |
| Non-proxy hosts | Hosts that should bypass the proxy | localhost | 127.0.0.1 | \*.example.org |
| Proxy environment variables | Alternative way to pass the settings | GRADLE_OPTS with -D flags |
Testing and troubleshooting the proxy
- Environment variables: Gradle does not read
HTTP_PROXYorHTTPS_PROXY. For settings that change between machines, put them in the per-user~/.gradle/gradle.properties, or pass the same JVM properties through theGRADLE_OPTSenvironment variable, for exampleGRADLE_OPTS="-Dhttps.proxyHost=proxy.example.com -Dhttps.proxyPort=8080". - Check connectivity: run a simple task such as
dependenciesto confirm Gradle can reach the repositories through the proxy. - Debug failures: run with
--debugto get detailed logs of connection problems. - Protect credentials: never commit proxy passwords to a repository or leave them in publicly accessible files.
Related reading
- Group authorization in AppSync using IAM authentication
- gRPC client not working when called from within gRPC service
- gRPC cpp async server vs sync server
- gRPC streaming inter instance communication
- Gradle script to autoversion and include the commit hash in Android
- Gradle Version 2.10 is required. Error
- GWT-RPC vs HTTP Call - which is better?
- HAProxy to use DNS from operating system?
System design interview problems on this topic
- Design a Load Balancer: solution and walkthrough
- Design a Domain Name System: solution and walkthrough
- Design a Global Content Distribution Network: solution and walkthrough
- Design an API Rate Limiter: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.