首页 > 解决方案 > vagrant (bento/ubuntu-16.04) 中的端口转发和 localhost 也没有打开

问题描述

我正在尝试使用带有 vagrant(bento/ubuntu-16.04)的数据库在 python 中创建一个 Web 服务器。

vagrant 支持所有端口转发。然后在执行 ``python webserver.py``` 但 localhost 没有打开之后。

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/ubuntu-16.04' version '2.3.5' is up to date...
==> 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: Forwarding ports...
   default: 8000 (guest) => 8000 (host) (adapter 1)
   default: 8080 (guest) => 8080 (host) (adapter 1)
   default: 5000 (guest) => 5000 (host) (adapter 1)
   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

然后 $ python webserver.py 显示“在端口 8080 上运行的 Web 服务器”

但本地主机没有打开。并展示这个

Safari cant open the page "localhost:8080/hello" because the server unexpected dropped the connection.

标签: pythonvagrantwebservercrudvagrantfile

解决方案


推荐阅读