Heim  >  Fragen und Antworten  >  Hauptteil

python flask部署报错?

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

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

PHP中文网PHP中文网2741 Tage vor363

Antworte allen(1)Ich werde antworten

  • 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'

    这是 flask 的 run 函数的源码,host未指定时,会默认赋为'127.0.0.1',而使用回送地址发送数据,协议软件立即返回,不进行任何网络传输。Temporary failure in name resolution,检查一下resolv.conf文件的dns设置。

    Antwort
    0
  • StornierenAntwort