-2
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 80 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: 80, host: 1234
Simon Staton
  • 4,345
  • 4
  • 27
  • 49

2 Answers2

0

It seems that when you say

When running lsof -i tcp:80 no service is returned and the same applies for other ports that I have tried.

you're confused between host and guest

so when it reads

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

It means that the port 80 from the guest VM will redirected on the host on port 1234, wether or not you have something running on the 80 port on the VM, it prepares the binding and make sure the port on the host is available.

so what you should really make sure is that nothing is running on the port 1234 on the host (not that port 80 has something or not) - If there's a process using the port, switch to another port or kill the process

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • I'm experiencing the same issue as Simon. '1234' is a random example from the error message, a suggestion of what to change the host port to. It's not the current host port. You see the host port earlier in the message, where it says, "The forwarded port to 80 is already in use on the host machine." – Qaz Jan 15 '17 at 19:44
0

If you're getting collisions even when the ports are unused and you're running VMware Fusion, sudo edit /Library/Preferences/VMware Fusion/vmnet8/nat.conf/ and delete (commenting wasn't enough for me) the lines in the format <external port number> = <VM's IP address>:<VM's port number>. For example, I deleted 80 = 192.168.12.150:80 and many others. Save the file and run vagrant up.

You may need to repeat this process when you restart your VM. There seems to be a problem with Fusion that makes it leave old entries in the config file even after the VM is shut down. I found out about it here: https://github.com/mitchellh/vagrant/issues/8130

Qaz
  • 1,556
  • 2
  • 20
  • 34