From hostmachine, how to access NodeJs App on my Virtual Machine?

12/18/2020

I have the following: 1. Windows 10 OS -- Host Machine 2. Oracle VirtualBox -- Guest Machine 3. A linux Server (ubuntu) 4. Minikube on Ubuntu for Kubernetes

I have written a simple nodejs app which should run on port 8087 inside a virtual box. The nodeapp is exposed via kubernetes service and then I have used "kubectl port-forward" to forward the request to kubernetes nodejs pod.

Now, if I do a curl localhost:9000 from my guest machine(ubuntu), I get a response back from the nodejs app. however when I try to do a curl from my host machine (windows) I do not get any response. I have used NAT connection and port forwarded from my host machine to guest machine on port 9000. Can anyone please help me why I am unable to access the 9000 port on my hst machnine?

-- Geebee
kubernetes
minikube
virtualbox

1 Answer

12/18/2020

ok, found the reason, I had to port forward kubectl with address:

kubectl port-forward  --address 0.0.0.0   hello-node-7797cfb8cb-7nkfk 9090:8087

and now I can access my nodejs app

enter image description here

-- Geebee
Source: StackOverflow