无法连接到Flask Web服务,连接被拒绝 [英] Can't connect to Flask web service, connection refused

查看:1598
本文介绍了无法连接到Flask Web服务,连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Flask在Raspberry Pi上运行一个简单的Web服务器。当我运行我的Flask应用程序时,它说:运行在 $ b


rel =noreferrer> http://127.0.0.1:5000/


但是当我输入这个地址我的笔记本电脑在Chrome中,我得到了

lockquote
ERR_CONNECTION_REFUSED
$ /

我可以在Raspberry Pi的浏览器上打开127.0.0.1:5000。我需要做什么从另一台计算机连接?

解决方案

运行您的应用程序:

  if __name__ =='__main__':
app.run(host ='0.0.0.0')

它将使服务器外部可见。如果机器的IP地址是 192.168.X.X ,则可以从同一网络以5000端口访问它。就像 http://192.168.X.X:5000


I'm trying to run a simple web server on a Raspberry Pi with Flask. When I run my Flask app, it says:

running on http://127.0.0.1:5000/

But when I enter this address on my laptop's in Chrome, I get

ERR_CONNECTION_REFUSED

I can open 127.0.0.1:5000 on the Raspberry Pi's browser. What do I need to do to connect from another computer?

解决方案

Run your app like this:

if __name__ == '__main__':
    app.run(host='0.0.0.0')

It will make the server externally visible. If the IP address of the machine is 192.168.X.X then, from the same network you can access it in 5000 port. Like, http://192.168.X.X:5000

这篇关于无法连接到Flask Web服务,连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆