Can't Access Kubernetes Service Exposed via NodePort
The error Connection Refused
mostly means that the application inside the container does not accept requests on the targeted interface or not mapped through the expected ports.
Things you need to be aware of:
- Make sure that your application bind to
0.0.0.0
so it can receive requests from outside the container either externally as in public or through other containers. - Make sure that your application is actually listening on the
containerPort
andtargetPort
as expect
In your case you have to make sure that ADDERSERVICE_SERVICE_HOST
equals to 0.0.0.0
and ADDERSERVICE_SERVICE_PORT
equals to 8080
which should be the same value as targetPort
in service.yml
and containerPort
in deployment.yml
Not answering the question but if someone who googled comes here like me who faced the same issue. Here is my solution for the same problem.
My Mac System IP and minikube IP are different.
So localhost:port didn't work instead try getting IP
minikube ip
Later, use that IP:Port to access the app and it works.
Check if service is really listening on 8080.
Try telnet within the container.
telnet 127.0.0.1 8080...telnet 172.17.0.5 8080