0

I have a vagrant box. I am already forwarding one port which looked like this

config.vm.network "forwarded_port", guest: 80, host: 8181

This works well but I want to forward another port and I added the following line below:

config.vm.network "forwarded_port", guest: 8080, host: 5555

I have an apache server listening at port 80 in the guest and I set up a python server to listen at 8080 in the guest too. In my host I visit 127.0.0.1:8181 and it works but if I visit 127.0.0.1:5555, I get this page is not working.

If it helps This is my network configuration in vagrant.

config.vm.network "forwarded_port", guest: 80, host: 8181
config.vm.network "forwarded_port", guest: 8080, host: 5555
config.vm.network "private_network", ip: 192.168.33.111

I have tried to add host_ip: "127.0.0.1" but it didn't change anything. I used vagrant reload after modifying my vagrantfile. What am I getting wrong here?

I followed information provided here: https://www.vagrantup.com/docs/networking/forwarded_ports.html

J.Ewa
  • 205
  • 3
  • 14

2 Answers2

0

It looks like you have the ports reversed. Change the 5555 line to this:

config.vm.network "forwarded_port", guest: 5555, host: 8080

Alternatively, you can just forward the same port:

config.vm.network "forwarded_port", guest: 5555, host: 5555
davejagoda
  • 2,420
  • 1
  • 20
  • 27
  • I just typed in wrong in the question. I set up the python server to listen at 8080. I have updated my answer to reflect this. – J.Ewa Oct 23 '18 at 08:35
0

Ok I was able to resolve this problem. You have to do ifconfig and grab your ip addres from inet section.

Use this address instead of localhost or 127.0.0.1 with any port you want to listen to if available. For me my ip was 10.0.2.15 and I listened at port 8080 and visited 127.0.0.1:5555 and it worked.

J.Ewa
  • 205
  • 3
  • 14