Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 金字塔博客教程可以';我看不到现场http://localhost:6543_Python_Pyramid - Fatal编程技术网

Python 金字塔博客教程可以';我看不到现场http://localhost:6543

Python 金字塔博客教程可以';我看不到现场http://localhost:6543,python,pyramid,Python,Pyramid,我有一台流浪机器作为我的开发环境运行 下面是使用pyramid(python)框架的简单博客教程中的步骤: 一切正常,直到我启动服务器。我收到服务器正在运行的消息 Starting subprocess with file monitor Starting server in PID 2605. Serving on http://localhost:6543 但是转到指定的URL会给我一个ERR\u CONNECTION\u densed错误 我认为这与它在虚拟机上运行有关。因此,当我进入本

我有一台流浪机器作为我的开发环境运行

下面是使用pyramid(python)框架的简单博客教程中的步骤:

一切正常,直到我启动服务器。我收到服务器正在运行的消息

Starting subprocess with file monitor
Starting server in PID 2605.
Serving on http://localhost:6543
但是转到指定的URL会给我一个
ERR\u CONNECTION\u densed
错误

我认为这与它在虚拟机上运行有关。因此,当我进入本地浏览器时,它会在我的Mac电脑上寻找一些东西,而不是我的虚拟机

我尝试将development.ini中的127.0.0.1引用更改为0.0.0.0,但这并没有解决问题


有人能告诉我发生了什么事以及如何解决吗?

找到了答案。它需要两个改变

在实际的vagrant文件中,我必须添加如下所示的端口映射,并销毁、重新启动vagrant机器

  config.vm.network "forwarded_port", guest: 6543, host: 6543
然后,在development.ini中,我不得不将ip更改为使用0.0.0.0:

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543

localhost
表示仅从运行此代码的计算机进行访问—在您的示例中,是从VM进行访问。您无法从外部计算机进行访问-即使是从此VM的主机进行访问。
0.0.0.0
应该可以从其他计算机进行访问-但是您可以使用防火墙,或者可以将VM配置为阻止外部连接。顺便说一句:但在web浏览器中,您必须使用此VM的IP,而不是
localhost
,也不是
0.0.0