首页 > 解决方案 > Vagrant Up (private_network) 错误:默认值:警告:连接中止。重试

问题描述

我有以下 Vagranfile。当 I 时vagrant up,我收到以下错误。但是,如果我切换到使用 a config.vm.network "public_network",一切正常。

但是我还是想用config.vm.network "private_network",所以我可以分配固定的IP地址进行开发。

[错误]

    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> 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: Connection aborted. Retrying...
    default: Warning: Connection aborted. Retrying...

[流浪文件]

Vagrant.configure("2") do |config|
  config.vm.box = "pef"

  config.vm.network "private_network", ip: "192.168.33.12"
  #config.vm.network "public_network"

  config.vm.synced_folder "C:/Users/user1/myprj", "/home/vagrant"

  config.vm.provider "virtualbox" do |vb|
     # Display the VirtualBox GUI when booting the machine
     vb.gui = true

     # Customize the amount of memory on the VM:
     vb.memory = "1024"

     # For host-only adapter
     vb.customize ["modifyvm", :id, "--uartmode1", "disconnected" ]
     vb.customize ["modifyvm", :id, "--nictype1", "Am79C973"]
     vb.customize ["modifyvm", :id, "--nictype2", "Am79C973"]
  end
end

标签: vagrantvirtualbox

解决方案


我有这个令人困惑的问题。您需要知道的第一件事是导致超时的问题。

如果您使用的是 VirtualBox,您可以将其添加到您的 VagrantFile 中:

   config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
     vb.gui = true

这将启动 VirtualBox 窗口并帮助您了解在 VM 启动过程中可能出现的错误。

就我而言,我尝试了几件事并最终将 Vagrant time out 提高到 600 :

  config.vm.boot_timeout = 600 

您还可以阅读 StackOverflow 上的此提要,它描述了相同的问题: Vagrant up timeout


推荐阅读