net::ERR_CONNECTION_TIMED_OUT from angular to nodejs in k8s

9/16/2017

I am trying to make request to nodejs backend from containerized AngularJS frontend to nodejs.

Both are deployed in AWS using Kubernetes(KOPS). And I created service to access both.

For frontend type is LoadBalancer in k8s services and for backend, its ClusterIP. I can access frontend from browser using URL of the load balancer which "kubectl get services" gives me. But when frontend tries to make request to backend I am getting following error:

net::ERR_CONNECTION_TIMED_OUT or net::ERR_NAME_NOT_RESOLVED. 

I checked using telnet etc, and app is running and can be accessed. Direct access to hostname works but doesn't work from AngularJS/NodeJS.

-- Swapnil B.
angularjs
kubernetes
node.js

3 Answers

9/17/2017

Your post was light on specifics, but if I understand correctly:

1. ELB -> Service -> Pod("http-server-serving-Angular")
2. ClusterIP -> Service -> Pod("nodejs")

Is that correct? because if so:

and for backend, its ClusterIP

Cluster IP addresses are, as their name suggests, only available within the cluster. You will want the backend Service to be of type LoadBalancer, also, so traffic that is not in the cluster can reach the nodejs app.

I'm cheating you with that answer just a tiny bit, because you can absolutely provision an Ingress controller and then leave the other Services as ClusterIP, but I would bet that's not the typical setup.

-- mdaniel
Source: StackOverflow

9/18/2017

i think i found the problem. Here is the possible cause. I am using express.js for frontend which is hosted in nodejs. We wrote service which makes connection to backend host. This is not being served through http server and this is making connection being made from client's browser. I tried adding public ip to backend and it was working as expected. So possible fix it serve express/angular from nodejs web server. This is not kubernetes question. I apologize for adding misleading tag.

Thanks for all the replies guys!

-- Swapnil B.
Source: StackOverflow

5/31/2018

So this problem was wrong rule in nginx controller. My ingress has typo which was causing frontend to not recognize url. This issue is resolved.

-- Swapnil B.
Source: StackOverflow