我试图启动一个实例流浪汉并获得以下信息:
Vagrant cannot forward the specified ports on this VM, since they
would collide with another VirtualBox virtual machine's forwarded
ports! The forwarded port to 4567 is already in use on the host
machine.
To fix this, modify your current projects Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:
config.vm.forward_port 80, 1234
我打开VirtualBox的,但我不此刻有任何正在运行的盒子,所以我难倒。 我怎样才能找出哪个进程在4567听吗? 有没有办法列出我的机器上运行的所有流浪盒?
谢谢,凯文
由于有消息称,该端口与主机盒碰撞。 我会简单地将端口更改为主机上的其他值。 所以,如果我收到错误
config.vm.forward_port 80, 1234
那么我将其更改为
config.vm.forward_port 80, 5656
作为1234可能我的主机上使用。
对于任何一台机器上实际检查口,我用的是tcpview
实用程序是操作系统和了解使用哪个端口的位置。
你可以看到流浪的实例你的机器上运行运行
$ vagrant global-status
id name provider state directory
----------------------------------------------------------------------
a20a0aa default virtualbox saved /Users/dude/Downloads/inst-MacOSX
64bc939 default virtualbox saved /Users/dude/svn/dev-vms/ubuntu14
a94fb0a default virtualbox running /Users/dude/svn/dev-vms/centos5
如果您没有看到任何虚拟机上运行,你的冲突不是一个无业游民箱(即流浪汉知道)。 接下来要做的事情是火了VirtualBox的UI,并检查是否有正在运行的任何实例。 如果你不希望运行的UI,您可以:
ps -ef |grep VBox
如果你有VirtualBox的情况下运行,他们应该被包括在输出。 您应该能够只杀死有VirtualBox的在它们的输出过程。 一个问题是,这些过程中的一个似乎存在做保持活动。 刚杀死的最高VirtualBox的过程。 如果你有一个VirtualBox的图像运行,但流浪者并不知道这件事,一些流浪目录可能已被手动删除,这意味着流浪失去跟踪的实例。
当心,你的Vagrantfile是不是带来了一个流浪盒/实例时所使用的唯一的一个 。
当你得到这样的:
~/dev/vagrant user$ vagrant reload
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 8001 is already in use
on the host machine.
To fix this, modify your current projects Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:
config.vm.network :forwarded_port, guest: 8001, 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.
~/dev/vagrant user$
实际上,您不仅使用Vagrantfile来自〜的/ dev /流浪汉也是一个从“盒子”,分布.box的文件,该文件通常设在这里:
~/.vagrant.d/boxes/trusty/0/virtualbox/Vagrantfile
如果你在它一看你会看到它有足够的默认端口映射:
$ cat ~/.vagrant.d/boxes//trusty/0/virtualbox/Vagrantfile
$script = <<SCRIPT
bzr branch lp:jujuredirector/quickstart /tmp/jujuredir
bash /tmp/jujuredir/setup-juju.sh
SCRIPT
Vagrant.configure("2") do |config|
# This Vagrantfile is auto-generated by 'vagrant package' to contain
# the MAC address of the box. Custom configuration should be placed in
# the actual 'Vagrantfile' in this box.
config.vm.base_mac = "080027DFD2C4"
config.vm.network :forwarded_port, guest: 22, host: 2122, host_ip: "127.0.0.1"
config.vm.network :forwarded_port, guest: 80, host: 6080, host_ip: "127.0.0.1"
config.vm.network :forwarded_port, guest: 8001, host: 8001, host_ip: "127.0.0.1"
config.vm.network "private_network", ip: "172.16.250.15"
config.vm.provision "shell", inline: $script
end
# Load include vagrant file if it exists after the auto-generated
# so it can override any of the settings
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile)
因此,继续和编辑这个文件,删除违规碰撞转发端口(S):
config.vm.network :forwarded_port, guest: 22, host: 2122, host_ip: "127.0.0.1"
config.vm.network :forwarded_port, guest: 80, host: 6080, host_ip: "127.0.0.1"
# config.vm.network :forwarded_port, guest: 8001, host: 8001, host_ip: "127.0.0.1"
通过:
~/dev/vagrant user$ cp ~/.vagrant.d/boxes//trusty/0/virtualbox/Vagrantfile ~/.vagrant.d/boxes//trusty/0/virtualbox/Vagrantfile.old
~/dev/vagrant user$ vi ~/.vagrant.d/boxes//trusty/0/virtualbox/Vagrantfile
并观看了其他Vagrantfiles列入即:
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
现在,它的工作原理:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'trusty'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: vagrant_default_1401234565101_12345
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2122 (adapter 1)
default: 80 => 6080 (adapter 1)
default: 22 => 2222 (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 timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => /Home/user/dev/vagrant/vagrant-docker
==> default: Running provisioner: shell...
default: Running: inline script
...
希望这可以帮助。
我就遇到了这个问题,它原来的RubyMine还拿着上的端口。 我发现哪个应用通过运行此命令(在我的案件31337)持有的端口:
lsof -i | grep LISTEN
产量
node 1396 richard.nienaber 7u IPv4 0xffffff802808b320 0t0 TCP *:20559 (LISTEN)
Dropbox 1404 richard.nienaber 19u IPv4 0xffffff8029736c20 0t0 TCP *:17500 (LISTEN)
Dropbox 1404 richard.nienaber 25u IPv4 0xffffff8027870160 0t0 TCP localhost:26165 (LISTEN)
rubymine 11668 richard.nienaber 39u IPv6 0xffffff8024d8e700 0t0 TCP *:26162 (LISTEN)
rubymine 11668 richard.nienaber 65u IPv6 0xffffff8020c6e440 0t0 TCP *:31337 (LISTEN)
rubymine 11668 richard.nienaber 109u IPv6 0xffffff8024d8df80 0t0 TCP localhost:6942 (LISTEN)
rubymine 11668 richard.nienaber 216u IPv6 0xffffff8020c6ef80 0t0 TCP localhost:63342 (LISTEN)
还要注意的是(在流浪1.6.4至少)有文件夹~/.vagrant.d/data/fp-leases
,具有名称文件,如8080
, 8081
等删除该文件夹的内容刚才帮我。
如果您使用的Proxifier(或类似的应用程序)首先尝试关闭它。 这是我经历过由于Proxifier上OSX 10.9的一个问题。
我遇到过这个问题,因为我有一个VM这是试图运行Postgres的,和我的Postgres端口5432我的本地机器上运行。
之后vagrant resume
,我得到了错误:
流浪者无法在此VM指定端口转发,因为他们将与上这些端口已在侦听其他应用程序冲突。 转发端口5432已经在主机上使用。
寻找什么在端口5432上运行:
o-ets-webdeveloper:portal me$ lsof -i :5432
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
postgres 1389 me 5u IPv6 0x681a62dc601cf1e3 0t0 TCP localhost:postgresql (LISTEN)
postgres 1389 me 6u IPv4 0x681a62dc6499362b 0t0 TCP localhost:postgresql (LISTEN)
原来这是当地的Postgres,杀死这些进程让我跑vagrant resume
成功。
我的看法:我没有在端口8000上运行的所有进程,所以本质上是端口转发没有工作。 修复:菲尔的答案提供了解决方案
~/.vagrant.d/boxes/
上述路径具有列出的端口8000。有一次,我修剪它们都使用下面的命令,我能够成功运行了流浪的无业游民文件的其他版本
vagrant box remove [name] --all
文章来源: How to debug “Vagrant cannot forward the specified ports on this VM” message