使用 WSL 2 在 Vagrant 中拒绝连接
Connection Refused in Vagrant using WSL 2
我正在尝试 WSL 2,也在尝试 Vagrant。我在 Ubuntu 20.04 中使用它并且它工作正常,但现在我在 Windows 10 中的 WSL 2 中遇到问题。我的问题可能是关于 WSL 上的 SSH 问题,似乎 127.0.0.1:222 无法连接到 Virtual Box 中的图像。理解有误请指正
涉及的技术版本
- Windows 10 版本 19042.630
- WSL 和 Windows10
中的 Vagrant 版本 2.2.14
- WSL 2 - Ubuntu20.04
- Virtual Box 6.1 仅在 Windows 10 主机
Vagrant 文件
Vagrant.configure("2") do |config|
config.vm.box = "base"
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.define "laravel_envoy" do |laravel_envoy|
laravel_envoy.vm.hostname = "192.168.12.12"
laravel_envoy.vm.box = "bento/ubuntu-18.04"
laravel_envoy.vm.network :private_network, ip: "192.168.12.12"
laravel_envoy.vm.provider "virtualbox" do |bionicv|
bionicv.memory = 4096
bionicv.cpus = 4
bionicv.customize ["modifyvm", :id, "--uartmode1", "disconnected"]
end
laravel_envoy.vm.synced_folder "/mnt/c/Users/jjmigz-win10/Code/gcp-home","/home/vagrant/Code/gcp-home"
end
config.vm.network "forwarded_port", guest: 8992, host: 8991, host_ip: "127.0.0.1"
end
原始文本错误
jmigzwsl@jmigzw10:/mnt/c/Users/jjmigz-win10/Code/laravel_gitlab_ci_cd_with_envoy$ vagrant up
Bringing machine 'laravel_envoy' up with 'virtualbox' provider...
==> laravel_envoy: Clearing any previously set forwarded ports...
==> laravel_envoy: Clearing any previously set network interfaces...
==> laravel_envoy: Preparing network interfaces based on configuration...
laravel_envoy: Adapter 1: nat
laravel_envoy: Adapter 2: hostonly
==> laravel_envoy: Forwarding ports...
laravel_envoy: 8992 (guest) => 8991 (host) (adapter 1)
laravel_envoy: 22 (guest) => 2222 (host) (adapter 1)
==> laravel_envoy: Running 'pre-boot' VM customizations...
==> laravel_envoy: Booting VM...
==> laravel_envoy: Waiting for machine to boot. This may take a few minutes...
laravel_envoy: SSH address: 127.0.0.1:2222
laravel_envoy: SSH username: vagrant
laravel_envoy: SSH auth method: password
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
~/.bashrc 配置
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
export PATH="$PATH:/mnt/c/Program Files/Oracle/VirtualBox"
export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/Users/jjmigz-win10/Code/laravel_gitlab_ci_cd_with_envoy"
我试过的
我试图将我的 host_ip: "127.0.0.1" 更改为我的 Vagrantfile 但是我仍然遇到错误,而且我无法在互联网上使用 WSL 2 找到像这个问题这样的真正解决方案。
我试图在 Vagrantfile
中添加此 config.vm.boot_timeout
但仍然出现错误
我试图在我的 Vagrantfile
中添加这个 bionicv.gui = true
但仍然出现错误
相关问题 - 已过时且未使用 WSL 2
Vagrant Warning: Connection refused. Retrying
Vagrant stuck connection timeout retrying
一些猴子补丁,你开始吧。
只需安装插件 vagrant plugin install virtualbox_WSL2
和 vagrant ssh
从 WSL2 开始工作。
我正在尝试 WSL 2,也在尝试 Vagrant。我在 Ubuntu 20.04 中使用它并且它工作正常,但现在我在 Windows 10 中的 WSL 2 中遇到问题。我的问题可能是关于 WSL 上的 SSH 问题,似乎 127.0.0.1:222 无法连接到 Virtual Box 中的图像。理解有误请指正
涉及的技术版本
- Windows 10 版本 19042.630
- WSL 和 Windows10 中的 Vagrant 版本 2.2.14
- WSL 2 - Ubuntu20.04
- Virtual Box 6.1 仅在 Windows 10 主机
Vagrant 文件
Vagrant.configure("2") do |config|
config.vm.box = "base"
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.define "laravel_envoy" do |laravel_envoy|
laravel_envoy.vm.hostname = "192.168.12.12"
laravel_envoy.vm.box = "bento/ubuntu-18.04"
laravel_envoy.vm.network :private_network, ip: "192.168.12.12"
laravel_envoy.vm.provider "virtualbox" do |bionicv|
bionicv.memory = 4096
bionicv.cpus = 4
bionicv.customize ["modifyvm", :id, "--uartmode1", "disconnected"]
end
laravel_envoy.vm.synced_folder "/mnt/c/Users/jjmigz-win10/Code/gcp-home","/home/vagrant/Code/gcp-home"
end
config.vm.network "forwarded_port", guest: 8992, host: 8991, host_ip: "127.0.0.1"
end
原始文本错误
jmigzwsl@jmigzw10:/mnt/c/Users/jjmigz-win10/Code/laravel_gitlab_ci_cd_with_envoy$ vagrant up
Bringing machine 'laravel_envoy' up with 'virtualbox' provider...
==> laravel_envoy: Clearing any previously set forwarded ports...
==> laravel_envoy: Clearing any previously set network interfaces...
==> laravel_envoy: Preparing network interfaces based on configuration...
laravel_envoy: Adapter 1: nat
laravel_envoy: Adapter 2: hostonly
==> laravel_envoy: Forwarding ports...
laravel_envoy: 8992 (guest) => 8991 (host) (adapter 1)
laravel_envoy: 22 (guest) => 2222 (host) (adapter 1)
==> laravel_envoy: Running 'pre-boot' VM customizations...
==> laravel_envoy: Booting VM...
==> laravel_envoy: Waiting for machine to boot. This may take a few minutes...
laravel_envoy: SSH address: 127.0.0.1:2222
laravel_envoy: SSH username: vagrant
laravel_envoy: SSH auth method: password
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
laravel_envoy: Warning: Connection refused. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
~/.bashrc 配置
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
export PATH="$PATH:/mnt/c/Program Files/Oracle/VirtualBox"
export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/Users/jjmigz-win10/Code/laravel_gitlab_ci_cd_with_envoy"
我试过的
我试图将我的 host_ip: "127.0.0.1" 更改为我的 Vagrantfile 但是我仍然遇到错误,而且我无法在互联网上使用 WSL 2 找到像这个问题这样的真正解决方案。
我试图在
Vagrantfile
中添加此config.vm.boot_timeout
但仍然出现错误我试图在我的
Vagrantfile
中添加这个bionicv.gui = true
但仍然出现错误
相关问题 - 已过时且未使用 WSL 2
Vagrant Warning: Connection refused. Retrying
Vagrant stuck connection timeout retrying
一些猴子补丁,你开始吧。
只需安装插件 vagrant plugin install virtualbox_WSL2
和 vagrant ssh
从 WSL2 开始工作。