Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I don't have a proxy, but Gradle says "Connect to 127.0.0.1:8888 [/127.0.0.1] failed", even after removing ~/.gradle

My gradle seems to insist on downloading packages from what looks like a proxy address. With this command I stop all Gradle daemons, remove any Gradle configuration, and build a random project from GitHub that has no proxy settings in its gradle.properties (I tried other projects, same result):

./gradlew  --stop ;\
pkill -f '.*GradleDaemon.*' ;\
rm -rf ~/.gradle ;\
env ;\
./gradlew build

The ./gradlew build part outputs this error:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'commons-app'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:4.0.0.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:4.0.0.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.0/gradle-4.0.0.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.0/gradle-4.0.0.pom'.
               > Connect to 127.0.0.1:8888 [/127.0.0.1] failed: Connection refused (Connection refused)

For reference, here is the output of the first commands, with a line break between each for clarity:

Stopping Daemon(s)
1 Daemon stopped

TERM_PROGRAM=Apple_Terminal
TERM=xterm-256color
SHELL=/bin/bash
TMPDIR=/var/folders/jh/ffpydh_90rz7fhyq9ycryhnw00plfm/T/
TERM_PROGRAM_VERSION=433
OLDPWD=/Users/nicolasraoul/src
TERM_SESSION_ID=59D12079-D9B2-4C13-8366-219454D7760C
USER=nicolasraoul
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.OejMgJbaF5/Listeners
PATH=/Users/nicolasraoul/Library/Android/sdk/emulator:/Users/nicolasraoul/Library/Android/sdk/tools:/usr/local/git/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/Users/nicolasraoul/Library/Python/2.7/bin
PWD=/Users/nicolasraoul/src/commons-app2
ANDROID_SDK=/Users/nicolasraoul/Library/Android/sdk
LANG=en_US.UTF-8
XPC_FLAGS=0x0
HISTCONTROL=
XPC_SERVICE_NAME=0
HOME=/Users/nicolasraoul
SHLVL=1
LOGNAME=nicolasraoul
_=/usr/bin/env

Downloading https://services.gradle.org/distributions/gradle-6.2.2-all.zip
[...]

What could be the problem?

I have found several similar questions, but none of their answers apply because:

  • I am using pure Gradle, so no Android Studio.
  • ~/.gradle is empty
  • I don't have a proxy and I have not willingly configured one anywhere. By the way gradle-6.2.2-all.zip gets downloaded fine as part of the build, so my Internet is working.

macOS Catalina 10.15.5

like image 877
Nicolas Raoul Avatar asked Jul 26 '20 08:07

Nicolas Raoul


2 Answers

If you had a proxy configured before but gradle still thinks that it is enabled, be sure to kill all gradle daemons:

pkill -f '.*GradleDaemon.*'
like image 50
Werner Altewischer Avatar answered Sep 30 '22 13:09

Werner Altewischer


It seems that you have some proxy settings which are redirecting your https traffic to 127.0.0.1:8888

Do you have the HTTPS_PROXY environment variable set?

Do you have https.proxyHost and https.proxyPort properties configured in $USER_HOME/.gradle/gradle.properties?

like image 23
lance-java Avatar answered Sep 30 '22 12:09

lance-java