<p>I have spent whole day looking for an answer why my node js app is not reachable from the internet when I run it on Kubernetes with loadbalancer as a service type. The solution was to change host from localhost to 0.0.0.0 in node js server app definition, but I still don’t know why?</p>

<p>I hope this saves one’s time in the future.</p>

D. Joe
<p>When you say that you set the host I guess you mean what the app is told to listen on in the listen function like <a href="https://stackoverflow.com/questions/33953447/express-app-server-listen-all-intefaces-instead-of-localhost-only">express app server . listen all intefaces instead of localhost only</a> You can bind to a particular address or leave it open to all by using the 0.0.0.0 mask (the zeros function as a mask for matching rather than a true IP address - <a href="https://stackoverflow.com/a/20778887/9705485">https://stackoverflow.com/a/20778887/9705485</a>).</p>

<p>I imagine you had your app running fine locally and were able to access it from your host machine with your localhost configuration. This would be because your local machine would be accessing it in a way that conforms to the mask. Your config was effectively saying only localhost can access this app. So when you ported to Kubernetes then your machine has to go over a network and the incoming connection was then your machine's external/public IP address, which then did not match the localhost mask. So to get it to work you changed the mask to make it open to all IPs. </p>
