Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vagrant

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

like image 269
Kevin Burke Avatar asked Jun 08 '12 17:06

Kevin Burke


1 Answers

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.

like image 80
bikeonastick Avatar answered Sep 19 '22 18:09

bikeonastick