1

I face an issue with port-forwarding and VirtualBox. I launch a linux vm using vagrant. SSH was already working with the port-forwading. The vm network is NAT.

Then I launch my flask application running on 5000. I declare the port-forwarding in VirtualBox.

image

But I can't access 127.0.0.1:5000 on my host. Host is Windows 7.

I already tried to reboot the vm and declare 127.0.0.1 as host ip.

10
  • if you are using NAT why do you need the port forward from your machine? you should be able to access the vm by it's IP. Now having that said, if your port forward works for 2222 to 22 and the second port forward does "not work" than it could be that your vm is blocking port 5000 or is using some redirection. so you should check with telnet 127.0.0.1 5000 if you get a response.
    – Zina
    Mar 11, 2016 at 10:39
  • This is what I get when I curl in my vm. It responds as expected. curl 127.0.0.1:5000 testvagrant@precise64:~$ telnet 127.0.0.1 5000 Trying 127.0.0.1... Connected to 127.0.0.1. Same thing with telnet. Mar 11, 2016 at 11:00
  • I assume you ran this on your host. So you get a response meaning the network part (port forward) is not a problem. Maybe you should check the flask app logs.
    – Zina
    Mar 11, 2016 at 11:08
  • no I run this on my guest to check if my app is running. I have no response if I run this on my host Mar 11, 2016 at 12:53
  • Sorry, didn't see your second comment. You have to check from your host machine. If it will not work then it is probably a firewall problem.
    – Zina
    Mar 11, 2016 at 12:56

1 Answer 1

1

Summary of the troubleshooting process in the comments:

The problem was not in port forwarding, it was that the flask app was listening only on localhost on the guest vm. After correcting the startup of the app to listen on all interfaces, the OP resolved his issue and was able to connect from his host.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .