Port forwardings not working

141 views
Skip to first unread message

Robert Chris Bang Larsen

unread,
Sep 9, 2015, 9:01:04 AM9/9/15
to Vagrant
I have VMWare workstation 12:
HOST $ vmware --version
VMware Workstation 12.0.0 build-2985596

And vagrant-vmware-workstation 4.0.1:
HOST $ vagrant plugin list
vagrant
-libvirt (0.0.30)
vagrant
-share (1.1.4, system)
vagrant
-vmware-workstation (4.0.1)

The guest is running:
HOST $ vagrant status
Current machine states:


default                   running (vmware_workstation)


The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down
, or you can run `vagrant suspend` to simply suspend
the
virtual machine. In either case, to restart it again, run
`vagrant up`.

I have forwarded port 80 on the host to port 80 on the guest:
HOST $ grep ' 80,' Vagrantfile
    config
.vm.network "forwarded_port", guest: 80, host: 80, auto_correct: true


However, I have a web server on the host, so Vagrant has allocated another port for the forward. In this case it is port 2201:
HOST $ cat .vagrant/machines/default/vmware_workstation/forwarded_ports
{"5280":5280,"5222":5222,"9001":9001,"9002":9002,"9003":9003,"9004":9004,"9999":9999,"5555":5555,"2200":27017,"2201":80,"8083":8083,"8086":8086,"3000":3000,"2222":22}

This seems to be true:
HOST $ sudo netstat -lnpt --inet|grep 2201
tcp        
0      0 0.0.0.0:2201            0.0.0.0:*               LISTEN      5706/vmnet-natd

However, I get a connection but no data on that port:
HOST $ timeout 5 HEAD http://localhost:2201 || echo "Timed out"
Timed out

But the port is available and quite chatty from inside the guest:
HOST $ vagrant ssh
Last login: Wed Sep  9 12:36:39 2015 from 172.16.203.1
[vagrant@localhost ~]$ HEAD http://localhost:80
200 OK
Connection: close
Date: Wed, 09 Sep 2015 12:39:06 GMT
Server: Apache/2.2.15 (CentOS)
Content-Type: text/html; charset=UTF-8
Client-Date: Wed, 09 Sep 2015 12:39:06 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
X
-Powered-By: PHP/5.3.3


[vagrant@localhost ~]$

Looking into VMWare Virtual Network Editor at the NAT device I see an empty list of port forwards both for my user and for root.

As we saw, we can ssh to the machine, so the 2222 port is forwarded fine:
HOST $ nc localhost 2222
SSH
-1.99-OpenSSH_5.3

How do I debug this further?

Also, why is vmnet-natd bound to 0.0.0.0:2201 when no host_ip was specified in the Vagrantfile? Shouldn't it default to localhost only?

- Robert

Alvaro Miranda Aguilera

unread,
Sep 10, 2015, 2:52:44 AM9/10/15
to vagra...@googlegroups.com
On Thu, Sep 10, 2015 at 1:01 AM, Robert Chris Bang Larsen
<rob...@the-playground.dk> wrote:
> config.vm.network "forwarded_port", guest: 80, host: 80, auto_correct: true

Hello

Port under 1024 are reserved and some OS won't allow a normal user to use them

Can you try with a higher port? say 8080

Thanks
Alvaro.

Robert Chris Bang Larsen

unread,
Sep 11, 2015, 2:58:44 AM9/11/15
to Vagrant
Vagrant noticed that it could not get port 80 and thus used 2201 but I tried specifying 8887 and got the same result.
Reply all
Reply to author
Forward
0 new messages