Python 3.1 http 服务器的快速问题
我在运行 3.1 附带的内置 Python 服务器时遇到问题,这可能是也可能不是 Python 的问题,事实上它可能不是。 正如文档所示(http://docs.python.org/release/3.1.3/library/http.server.html),我使用“python -m http.server 8000”在正确的目录中启动服务器。 当我使用 url 192.168.2.104:8000(我的本地 IP 和端口)导航到本地网络上的该端口时,我的页面会加载。然而,当我使用我的全球 IP 时,它就停止工作了。 8000端口转发正确。我使用 www.yougetsignal.com 来验证端口 8000 是否已使用我的全局 IP 开放。为什么 Chrome 会说“哎呀!Google Chrome 无法连接到 [已编辑]:8000”呢?其他服务器应用程序(例如我的 Minecraft 服务器)工作得很好。我有什么遗漏的吗?此外,为什么 yougetsignal 连接到我的端口而不是 Chrome?
I'm have an issue with running the built in Python server that comes with 3.1, this may or may not be an issue with Python, in fact it probably isn't.
I start my server in the correct directory with "python -m http.server 8000" as the documentation suggests (http://docs.python.org/release/3.1.3/library/http.server.html).
When I navigate to that port on my local network with another computer using the url 192.168.2.104:8000 (my local ip and the port) my page loads. When I use my global IP, however, it stops working. Port 8000 is forwarded correctly. I used www.yougetsignal.com to verify that port 8000 was open using my global IP. Why in the world would Chrome be saying "Oops! Google Chrome could not connect to [REDACTED]:8000" then? Other server applications (such as my Minecraft server) work just fine. Is there something I'm missing? Furthermore, why would yougetsignal connect to my port but not Chrome?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于大多数路由器,仅当有人从外部(互联网/WAN)连接时才会映射端口。您正在从 LAN 进行测试,因此当您使用公共 IP 时,基本上您是在连接到路由器。请朋友进行测试,即通过外部连接进行测试。
With most routers ports are only mapped when someone connects from the outside (internet/WAN). You're testing it from your LAN so basically you're connecting to your router when you use your public IP. Ask a friend to test, i.e. from an outside connection.