Vagrant Port Collisions

148 views
Skip to first unread message

Andrew MacNamara

unread,
Dec 8, 2016, 4:42:33 PM12/8/16
to Vagrant
I've recently begun having issues with Vagrant port forwarding.  I recently got a new Macbook Pro, and migrated my Vagrant project over.  I tried starting my vagrant box on the new machine for the first time, and it failed to start, due to port collisions.  

config.vm.network "forwarded_port", guest: 7001,  host: 7001

This gave me the error:

Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 7001 is already in use
on the host machine.

To resolve this, I switched the host port to 7002.  This worked for about a day, then I started to receive the message:

Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 7002 is already in use
on the host machine.

I initially experienced this with Vagrant 1.9.1, but reverted back to 1.8.6 and am still experiencing the same issue.

netstat -a | grep 7001 does not return any results.

Alvaro Miranda Aguilera

unread,
Dec 10, 2016, 3:13:36 PM12/10/16
to vagra...@googlegroups.com
hello,

This is on VMWare or Virtualbox?

In VMWare are issues on 8.5.1 and 8.1.0 and 8.1.1

8.5.2, 8.5.0, 8.0.2 are fine.

If not on VMWare, can you share gist when it works and fail?

VAGRANT_LOG=debug vagrant up

Thanks!
Alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/7f692d28-7896-4f28-9d2b-9d310d05df61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Andrew MacNamara

unread,
Dec 12, 2016, 10:20:04 AM12/12/16
to Vagrant
I'm on VMWare Version 8.5.3 (4696910).

Andrew MacNamara

unread,
Dec 16, 2016, 3:43:18 PM12/16/16
to Vagrant
Found that the port forwarding in VMWare Fusion is managed in the file: /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf

It appears that the forwarded ports get written to this file, but are never removed.   There's a section:

# Use these with care - anyone can enter into your VM through these...
# The format and example are as follows:
#<external port number> = <VM's IP address>:<VM's port number>

And the vagrant port forwarding gets written here as 
# VAGRANT-BEGIN: /Users/....../.vagrant/machines/default/vmware_fusion/8155631a-1c29-42a1-9a4f-0567011f98bd/oel66.vmx
# VAGRANT-END: /Users/......../.vagrant/machines/default/vmware_fusion/8155631a-1c29-42a1-9a4f-0567011f98bd/oel66.vmx


After stopping and starting the vagrant box, the entry for 2222 gets moved out of the VAGRANT-BEGIN/END section, and is left behind.  Meanwhile, a new entry is added to the VAGRANT-BEGIN/END section, since vagrant fixes the port collisions.

Alvaro Miranda Aguilera

unread,
Dec 17, 2016, 6:20:49 AM12/17/16
to vagra...@googlegroups.com
Hello.

What version of Vagrant and Vmware are you using ?

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Chris Bandy

unread,
Dec 20, 2016, 12:20:36 PM12/20/16
to Vagrant
Alvaro,

I am experiencing this same issue on macOS 10.12.1 with Vagrant 1.8.4 and VMware Fusion 8.5.3 (4696910).

Per Andrew's suggestion, I tried deleting lines from the [incomingtcp] section of '/Library/Preferences/VMware Fusion/vmnet8/nat.conf'. However, when starting the box vagrant continued to find a port collision and the lines I deleted reappeared.

Exploring this preferences folder further, I found another file, '/Library/Preferences/VMware Fusion/networking', with the following lines:

add_nat_portfwd 8 tcp 2200 192.168.52.185 22
add_nat_portfwd 8 tcp 2201 192.168.52.185 22
add_nat_portfwd 8 tcp 2202 192.168.52.185 22
add_nat_portfwd 8 tcp 2203 192.168.52.185 22
add_nat_portfwd 8 tcp 2204 192.168.52.185 22
add_nat_portfwd 8 tcp 2222 192.168.52.185 22

When I delete these (along with those in 'nat.conf',) vagrant no longer reports a collision during startup. However, this only lasts for one boot. Issuing a `vagrant halt && vagrant up` triggers another port collision and additional lines in both preference files.

-- Chris

Alvaro Miranda Aguilera

unread,
Dec 20, 2016, 2:32:55 PM12/20/16
to vagra...@googlegroups.com
Hello.

Can you update to Vagrant 1.9.1 and then update the plugin ?

vagrant plugin list
vagrant plugin install <plugin>

Install will force reinstall/update of the plugin.

Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Chris Bandy

unread,
Jan 3, 2017, 11:34:51 AM1/3/17
to Vagrant
I encountered multiple software updates over the last few weeks. I did as you recommended and the issue appears to be resolved.

macOS 10.12.2
VMware Fusion 8.5.3 (4696910)
Vagrant 1.9.1

$ vagrant plugin list
vagrant-share (1.1.6)
  - Version Constraint: > 0
vagrant-vmware-fusion (4.0.15)
  - Version Constraint: > 0


Thanks!

-- Chris

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages