LoginSignup
1
4

More than 5 years have passed since last update.

vagrantの起動に失敗する場合のTips3点(windows)

Posted at

株式会社オズビジョン@terra_yuccoです。

業務でも、enPiTプログラムでも、開発環境にはvagrantを利用しています。
業務ではあまり直面しないのですが、enPiTプログラムではvagrantが起動しない壁に良く突き当たるので、参照したサイトのリンクとともに、Tryの記録を残したいと思います。

環境

  • Windows 10 Home
  • Vagrant 1.8.4
  • VirtualBox 5.0.24 r108355

1: アップデート確認から進まない

  • 事象
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'xxxxx/yyyyy' is up to date...
  • 対処
    • vagrantファイルの以下の行のコメントを解除します。
      • ただし推奨設定ではありません
      • 本当はなんでそこで止まるのかチェックするべきではあります
# config.vm.box_check_update = false

2: ポートが衝突している

  • 事象
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'xxxxx/yyyyy' is up to date...
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 3000 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: 3000, 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.
  • 対処
    • もしVagrantfile内に重複エントリがあったり、別のVagrantが上がっていてぶつかるのであればポートをずらしましょう。
    • 自分は以下の設定を有効にしていたらぶつかったので、よくわからず切ってみたら起動したりしました。
# config.vm.network "private_network", ip: "192.168.33.10"
# config.vm.network "public_network"

3: sshに繋がらない

  • 事象
(前略)
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
      :
      :
  • 対処
    • とりあえず待つ。
    • Windowsだと裏でUACコントロールがポートを開ける許諾を求めていることがあります。必要なところだけはファイアウォールに穴を開けましょう。

appendix: それでも上がらない

あ、石を投げないで...

  • Windowsを再起動する
  • VirtualBoxのプロセスを一度落とす

今まで何度か上記の手段を取っていますが、特にVirtualBoxのプロセスを落とすは凄く効果的です。
塞いだ覚えのないポートが塞がれているときなどは、前に挙げていたVagrantが無事に落ちきっていないというケースが多いような…?

参考にしたサイト、ページ

それではよいvagrantライフを!
おしまい。

1
4
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
1
4