Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinioClient: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9000 #2

Open
dwhitejazz opened this issue Jun 2, 2020 · 9 comments

Comments

@dwhitejazz
Copy link

I have been looking for an Microservice example that uses docker and kubernetes with minikube.

Working through this example I am stuck trying to run the microservice. The docker containers start up and run for mongodb and knote but the microservice always fails to connect with following exception:

Minio Reconnect: true
java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9000
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:265)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:183)
at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224)
at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)
at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)
at okhttp3.internal.connection.Transmitter.newExchange(Transmitter.java:169)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
at okhttp3.RealCall.execute(RealCall.java:81)
at io.minio.MinioClient.executeReq(MinioClient.java:1111)
at io.minio.MinioClient.execute(MinioClient.java:1070)
at io.minio.MinioClient.updateRegionCache(MinioClient.java:1219)
at io.minio.MinioClient.getRegion(MinioClient.java:1264)
at io.minio.MinioClient.executeHead(MinioClient.java:1312)
at io.minio.MinioClient.bucketExists(MinioClient.java:3286)
at io.learnk8s.demo.KNoteController.initMinio(KnoteJavaApplication.java:169)
at io.learnk8s.demo.KNoteController.init(KnoteJavaApplication.java:118)

This is probably a configuration issue on my end but I am unable to determine why this is happening and how to the resolve it. Perhaps related to localhost and a difference between 127.0.0.1 and 0.0.0.0?

My docker image is deployed:
knote-java latest ce9109e6c6df About an hour ago 393MB

Mongodb is running in a docker container:
2020-06-02T01:04:34.139+0000 I NETWORK [listener] Listening on 0.0.0.0
2020-06-02T01:04:34.139+0000 I NETWORK [listener] waiting for connections on port 27017

docker ps looks right too:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c7b4df5e8318 knote-java "/bin/sh -c 'exec ja…" 32 seconds ago Up 30 seconds 0.0.0.0:8080->8080/tcp knote-java
23d5ed2a1fc5 mongo "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 27017/tcp mongo
482ae31f5632 gcr.io/k8s-minikube/kicbase:v0.0.10 "/usr/local/bin/entr…" 6 days ago Up 4 minutes 127.0.0.1:32787->22/tcp, 127.0.0.1:32786->2376/tcp, 127.0.0.1:32785->5000/tcp, 127.0.0.1:32784->8443/tcp minikube

Any assistance is greatly appreciated. Thank you.

@dwhitejazz
Copy link
Author

Attempting to use the browser localhost:8080 does not work, but I'm guessing that is because the microservice is not getting past the MinioClient connect operation.

@dwhitejazz
Copy link
Author

Please help. Any ideas on why this error is happening?

@salaboy
Copy link
Collaborator

salaboy commented Jul 30, 2020

@dwhitejazz sorry for the lack of response.. I was not getting notifications for this repo.. now I am..
can you share your kubectl describe pod <POD ID> output? I guess that it might be a missing env variable as it shouldn't point to localhost/127.0.0.1:9000

@lukasz-cpu
Copy link

lukasz-cpu commented Aug 13, 2020

@salaboy
I have the same issue.

@hendisantika
Copy link

Where is minio configuration properties?
I didn't see in on the tutorial.

@salaboy
Copy link
Collaborator

salaboy commented Oct 13, 2020

@dcnis
Copy link

dcnis commented Jan 25, 2022

I have the same issue. Cannot connect to my local docker container running on http://localhost:9000. I always get the same error message "java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9000"

@GetRhymes
Copy link

GetRhymes commented Oct 22, 2022

Faced the same problem and found its solution. In my case, I started 2 docker containers: one for the backend and the second for minio. When I specified the parameters for connecting minio, I also specified localhost:9000, but this is wrong! When minio starts, it outputs a log with parameters for connection, it looks something like this:

minio_1 | MinIO Object Storage Server
minio_1 | Copyright: 2015-2022 MinIO, Inc.
minio_1 | License: GNU AGPLv3 https://www.gnu.org/licenses/agpl-3.0.html
minio_1 | Version: RELEASE.2022-10-20T00-55-09Z (go1.19.2 linux/amd64)
minio_1 |
minio_1 | Status: 1 Online, 0 Offline.
minio_1 | API: http://172.18.0.2:9000 http://127.0.0.1:9000
minio_1 | Console: http://172.18.0.2:9001 http://127.0.0.1:9001

minio_1 |
minio_1 | Documentation: https://min.io/docs/minio/linux/index.html

We are interested in 2 lines that I highlighted in bold, of which you should take the first host (http://172.18.0.2:9000 ) and then everything will work for you!

@S-Shreesha
Copy link

@GetRhymes, Thanks!!
It works!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants