Perspective Unspoken

My perspective on Git, Docker, Python, Django, PHP and other stuff


Avoiding port collision running several Vagrant machines

Well, I’m not sure why this setting wasn’t the default but Vagrant actually allows you to tell it to find another port if the one it wants to forward is being used. It’s also dead simple and works like a charm. I only wish I could configure where it starts looking for ports.

Just add an extra parameter to the definition of your port forward:

Now whenever there’s a collision with a running machine you can effortlessly run other Vagrant instances. You’ll need to look at the output though to determine what the new forwards are.


You’ll want to pay attention to the new forwarding information though. Apparently there’s no way to get a list of forward ports after you’ve brought up the machine using Vagrant. You can open up Virtual Box though, find the VM, open up Setting and go to the Network tab.


Once you figure out which adapter it’s using, click the Port Forwarding button at the bottom. That’ll show you which ports are forwarded.




Well, hope this helps.

jaywhy13 • December 23, 2015

Previous Post

Next Post