How to debug "Vagrant cannot forward the specified ports on this VM" message

Kevin Burke picture Kevin Burke · Jun 8, 2012 · Viewed 51.6k times · Source

I'm trying to start a Vagrant instance and getting the following message:

Vagrant cannot forward the specified ports on this VM, since they
would collide with another VirtualBox virtual machine's forwarded
ports! The forwarded port to 4567 is already in use on the host
machine.

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

  config.vm.forward_port 80, 1234

I opened VirtualBox, but I don't have any running boxes at the moment, so I'm stumped. How can I figure out which process is listening on 4567? Is there a way to list all Vagrant boxes running on my machine?

Thanks, Kevin

Answer

bikeonastick picture bikeonastick · Jun 1, 2013

You can see what vagrant instances are running on your machine by running

$ vagrant global-status
id       name    provider   state   directory
----------------------------------------------------------------------
a20a0aa  default virtualbox saved   /Users/dude/Downloads/inst-MacOSX
64bc939  default virtualbox saved   /Users/dude/svn/dev-vms/ubuntu14
a94fb0a  default virtualbox running /Users/dude/svn/dev-vms/centos5

If you don't see any VMs running, your conflict is not a vagrant box (that vagrant knows about). The next thing to do is to fire up the VirtualBox UI, and check to see if it has any instances running. If you don't want to run the UI, you can:

ps -ef |grep VBox

If you have VirtualBox instances running, they should be included in that output. You should be able to just kill processes that have VirtualBox in their output. One problem is that one of those processes seems to exist to do keep-alives. Just kill off the highest VirtualBox process. If you have a VirtualBox image running but vagrant doesn't know about it, some Vagrant directories may have been deleted manually, which means Vagrant loses track of the instance.