【问题标题】:Port Collision on port 80端口 80 上的端口冲突
【发布时间】:2015-06-02 14:48:28
【问题描述】:

很长一段时间以来(大约 2 周),我第一次重新启动了 iMac。当我尝试通过homestead 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 80 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: 8000, 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.

我没有其他虚拟盒子在运行。我跑了sudo lsof -i :80,得到了以下列表:

COMMAND    PID        USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
Google     391 jamesspence   85u  IPv4 0xe9a8a2357c33587      0t0  TCP 192.168.1.84:49665->ord08s12-in-f28.1e100.net:http (ESTABLISHED)
Google     391 jamesspence   86u  IPv4 0xe9a8a235682a727      0t0  TCP 192.168.1.84:49666->ord31s22-in-f6.1e100.net:http (ESTABLISHED)
Google     391 jamesspence  249u  IPv4 0xe9a8a234f7d0247      0t0  TCP 192.168.1.84:49215->ec2-54-82-95-91.compute-1.amazonaws.com:http (ESTABLISHED)
httpd     1240        root    5u  IPv6 0xe9a8a234f7e08a7      0t0  TCP *:http (LISTEN)
httpd     1241        _www    5u  IPv6 0xe9a8a234f7e08a7      0t0  TCP *:http (LISTEN)

“Google”进程似乎是 Chrome,因为杀死它会杀死我的浏览器。 Apache2 似乎也在这个端口上运行。所以,用sudo apachectl stop 停止它似乎有帮助。当我这样做时,我通过了端口冲突阶段。但是,然后我的虚拟盒子在形成连接时挂断了:

default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...

我已经无计可施了。不到 24 小时前,我的 vagrant box 运行良好,没有问题。我不知道从哪里开始。有人知道我接下来应该做什么吗?

【问题讨论】:

    标签: apache vagrant homestead


    【解决方案1】:

    我最终通过安全启动(最初启动时按住 Shift 键)启动修复它,然后重新启动。在那之后,我仍然遇到connection timeout 问题,但只是手动启动和停止 virtualbox 修复了这个问题,现在一切正常。

    【讨论】:

      【解决方案2】:

      您的第一条消息的意思是您的端口转发无效,因为它使用了您的主机(因此是您的 Mac)上的 80 端口,并且该端口的使用方式与您在 Chrome 和其他方面识别它的方式相同。您应该尝试在您的 Vagrantfile 中放入正确的转发,如下所示:

      config.vm.network "forwarded_port", guest: 80, host: 8080 #http-apache
      

      然后使用localhost:8080 而不是默认的localhost:80(与localhost 相同)访问您的虚拟机。

      希望这会有所帮助。

      【讨论】:

      • 但问题在于,它正在访问该访客端口,尝试转发它并引发错误。更改主机端口并不能解决任何问题。
      • 你能分享你的 Vagrantfile 吗?我相信答案就在那里,因为您的解决方案似乎有点老套,而不是真正的解决方案。
      • 我正在使用Laravel Homestead,它有一个我没有接触过的预配置VagrantFile。
      猜你喜欢
      • 1970-01-01
      • 2016-07-22
      • 1970-01-01
      • 1970-01-01
      • 2021-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-06
      相关资源
      最近更新 更多