LoginSignup
2
1

More than 5 years have passed since last update.

Vagrant cannot forward the specified ports on this VM, since they would collide with some other application that is already listening on these ports. の解決方法

Posted at

forwarded_portして、特定のポートをvagrantfileで指定し,
vagrant upした時に出てくるエラーの解決方法。

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: 80, 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.

これはすでに他のポートが使用されているからなので、他で使われているポートを確認=>killすればOK。

使用しているプロセスのポート番号を確認

例えば、8080ポートを使っているプロセスを確認したい時

$sudo lsof -i tcp:8080
COMMAND     PID       USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
VBoxHeadl 47319       hoge   19u  IPv4 0x8dcbc04453b308b      0t0  TCP *:http-alt (LISTEN)

ポートを閉じる(プロセスを終了する)

上記で出てきたプロセス(PID)をkillする。

$kill 47319
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1