dandan611 / Settler

0 stars 0 forks source link

ポートがすでに利用されているとvagrant upに失敗する #7

Closed dandan611 closed 6 years ago

dandan611 commented 6 years ago

現象

xxx@PM888N ~/work/Settler/env_devmng
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos-7.4'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-7.4' is up to date...
==> default: Setting the name of the VM: devel_manage
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 10080 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: 10080, 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. You could
try 'vagrant reload' (equivalent of running a halt followed by an up)
so vagrant can attempt to auto-correct this upon booting. Be warned
that any unsaved work might be lost.

原因

host_ipを指定していないために発生。指定していないと、0.0.0.0を参照するとポートが占有されてしまっていた。正しく利用するのであれば、127.0.0.1を指定する必要があるというIssueがvagrantのリポジトリのIssueに上がっている。

対処

下記のようにhost_ipを追加する。

 config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1", id: "Product", auto_correct: true