vagrant upしようとすると「To fix this, modify your current project’s Vagrantfile to use another port. Example, where ‘1234’ would be replaced by a unique host port:」というエラーがでる。

Vagrant

Vagrantでvaguran upしようとしたら「ポートが既に使われている」という内容のエラーが出る。

$ vagrant up
Bringing machine '***' up with 'virtualbox' provider...
==> api: Checking if box '***.box' is up to date...
==> api: Fixed port collision for ** => ****. Now on port ****.
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 8080 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: **, host: ****

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.

 

えーなんか使ってたっけ…わからん…となった時、ポート番号からプロセスを探してkillすればOK。

lsof コマンドでプロセスを探します。

$ sudo lsof -i:8080
Password:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
>localhost:8808 (ESTABLISHED)
VBoxHeadl 12345 **** 19u IPv4 0xd03f8bbe585b56ad 0t0 TCP *:8080 (LISTEN)
VBoxHeadl 12345 **** 24u IPv4 0xd03f8bbe62fdd00d 0t0 TCP localhost:8080->localhost:50926 (ESTABLISHED)
VBoxHeadl 12345 **** 25u IPv4 0xd03f8bbe62fdd96d 0t0 TCP localhost:8080->localhost:50927 (ESTABLISHED)

PIDを指定してkillする。

$ kill 12345

 

これでvagrant up できると思う。

 

コメント/ピンバック

タイトルとURLをコピーしました