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

后端 未结 13 2718
时光取名叫无心
时光取名叫无心 2020-12-25 10:33

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 wi         


        
13条回答
  •  星月不相逢
    2020-12-25 10:43

    Watch out, your Vagrantfile is not the only one being used when bringing up a Vagrant box/instance.

    When you get this:

    ~/dev/vagrant user$ vagrant reload
    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 8001 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.network :forwarded_port, guest: 8001, host: 1234
    
    Sometimes, Vagrant will attempt to auto-correct this for you. In this
    case, Vagrant was unable to. This is usually because the guest machine
    is in a state which doesn't allow modifying port forwarding.
    ~/dev/vagrant user$ 
    

    You are actually not only using the Vagrantfile from ~/dev/vagrant but also the one from your "box" distribution .box file which is typically located here:

    ~/.vagrant.d/boxes/trusty/0/virtualbox/Vagrantfile
    

    And if you have a look at it you'll see it has plenty of default port mappings:

    $ cat ~/.vagrant.d/boxes//trusty/0/virtualbox/Vagrantfile
    $script = <
    
                                     
                  
提交回复
热议问题