4

I'm getting a port collision on all the ports in my Vagrantfile which seems to work fine for a time then suddenly something changes and it refuses to work. Please no answers saying "change your port"

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 3100 is already in use
on the host machine.

To fix this, modify your current project's Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:

  config.vm.network :forwarded_port, guest: 1337, host: 1234

I have done what i can to find the problem but it's elluding me at the moment.

lsof -n -i4TCP:3100

Outputs nothing

I'm running vagrant 1.9.2 with vagrant-vmware-fusion (4.0.18)

Nick
  • 589
  • 1
  • 7
  • 28
  • can you try the `auto_correct` option ? like `config.vm.network :forwarded_port, guest: 1337, host: 1234, auto_correct: true` – Frederic Henri Mar 23 '17 at 13:25
  • Yeah of course auto_correct works. I would just rather find out why vagrant is reporting a collision when none seems to exist. – Nick Mar 23 '17 at 13:32
  • do you get consistent information running netstat ? – Frederic Henri Mar 23 '17 at 14:00
  • Yeah - both show nothing running netstat -anv | grep 3100 lsof -i -n -P | grep TCP | grep 3100 – Nick Mar 23 '17 at 14:04
  • You should give us more info. When you try to connect, what does change in the log files (`ls -ltra /var/log`). How is your firewall configured, Specally the part for forwarding (`iptables -t nat -L -v -n`). Does your network work (`ip addr show` & `ip route`). What are the ports on the server and is the server listening and active (`netstat -tulpen`) . Did you try `telnet` or `ssh` and do you have the same problems with it ? – Mario Mar 26 '17 at 13:15
  • Thanks @suleiman for your comment. This isn't about connecting, it happens when the VM is coming up (and therefore performing the port forwarding). There is no firewall on my local machine (again not about connecting). Yep the network works absolutely fine (and if i change the port it works fine too). No problems with ssh. It feels like something is holding onto the ports and not allowing them to be forwarded even though nothing is actively listening – Nick Mar 27 '17 at 12:35
  • Forwarding has to to do with `iptables` and is a part of `netfilter`. You could have a wrong `MTU` or some other worng netfilter rules are applied. If not, log files are a main source to figure out errors too. Then there are `/etc/hosts.allow` and `/etc/hosts.deny` for access-control too. – Mario Mar 27 '17 at 12:47
  • @suleiman question is tagged as `OSX`. No `iptables` nor `netfilter` but BSD's `pf`. :) – clt60 Mar 29 '17 at 15:35

1 Answers1

5

Ok i think i've cracked it. It seems to be related to this issue

https://github.com/mitchellh/vagrant/issues/7948

the vagrant-vmware-plugin isn't clearing out the nat.conf in fusion. Therefore it still thinks that the ports are in use when they aren't.

editing /Library/Preferences/VMware Fusion/vmnet8/nat.conf and removing the offending entries in the [incomingtcp] section appears to solve it.

Guess it's just about managing that until a proper fix becomes available.

For reference this is fusion 8.5.3 and vagrant-vmware-fusion 4.0.18.

Nick
  • 589
  • 1
  • 7
  • 28