Home  >  Q&A  >  body text

python flask部署报错?

在使用flask部署在云端的时候,run函数里没有指定host,发现不能访问到。在网上查资料中发现需要指定host="0.0.0.0"才可以在公网访问到。但指定后flaskTemporary failure in name resolution不知如何解决?

请问各位,为什么不指定host的时候公网无法访问,指定后为什么会报这个错,该如何解决?
谢谢大家。

PHP中文网PHP中文网2741 days ago361

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 09:45:18

    def run(self, host=None, port=None, debug=None, **options):
        if host is None:
            host = '127.0.0.1'

    This is for flask run 函数的源码,host未指定时,会默认赋为'127.0.0.1',而使用回送地址发送数据,协议软件立即返回,不进行任何网络传输。Temporary failure in name resolution, check the dns settings of the resolv.conf file.

    reply
    0
  • Cancelreply