Gradle refuses a repository that uses http:// instead of https://
The build fails on a repository whose url starts with http://Short answer
Gradle does not talk to a repository over plain HTTP unless that repository opts in. Find the repository whose url starts with http://, switch it to https:// if the server supports it, or set allowInsecureProtocol to true inside that one repository block. There is no global switch.
Fix it fast
1Find out which cause you have
List every repository URL in the build files. Any line that starts with http:// is a candidate, including the ones in settings and in buildscript blocks.
grep -rn --include=*.gradle --include=*.gradle.kts --include=*.properties "http://" .2Match what you see, then jump to its fix
What does the error look like?
The build fails on a repository whose url starts with http://Android Studio sync fails while resolving a dependency from a self-hosted or LAN Maven repositorySetting allowInsecureProtocol in gradle.properties changes nothing
Cause 1 of 2
A repository is declared with an http:// URL
1Check
Open the file and the block that grep found. The same address may be declared more than once: in settings.gradle, in the root build file, in a buildscript block and in a module.
grep -rn -B2 -A3 "http://" settings.gradle* build.gradle* app/build.gradle*2Fix
First try the https:// form of the same address. If the server only speaks HTTP (an internal host, for example), opt in on that repository only. Gradle documents this as a per-repository choice.
// Kotlin DSL
maven {
url = uri("http://repo.internal.example:8081/releases")
isAllowInsecureProtocol = true
}
// Groovy DSL
maven {
url "http://repo.internal.example:8081/releases"
allowInsecureProtocol = true
}3Verify
Sync or run a build that resolves a dependency from that repository.
./gradlew build --refresh-dependenciesConfirmed by docs.gradle.org
Cause 2 of 2
You tried to switch the check off for the whole build
1Check
Search the Gradle properties files for the name. Gradle says it intentionally has no global system or Gradle property that disables this check, so such a line has no effect.
grep -n -i "insecure" gradle.properties ~/.gradle/gradle.properties2Fix
Delete the property and set the flag on each repository that needs it, as in the first cause. Prefer moving the repository to HTTPS: the Gradle reference warns that plain HTTP lets a man-in-the-middle impersonate the server and serve malicious code.
# remove any line like this from gradle.properties
# allowInsecureProtocol=true3Verify
Run the build again; the repository is now accepted because of its own flag.
./gradlew buildConfirmed by docs.gradle.org
How do I stop it coming back?
- Serve every internal Maven repository over HTTPS with a real or internal-CA certificate, so no flag is needed.
- Keep all repository declarations in one place (dependencyResolutionManagement in settings) so there is one URL to change.
- Review any build change that adds allowInsecureProtocol; it should name one host, not a wildcard habit.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile apps
Android Studio cannot pair the phone over Wi-Fi
The Pair devices over Wi-Fi dialog lists no device
Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.
4 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fix