最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]Flask运行出错:socket.gaierror Errno -2 Name or service not known

Flask crifan 5447浏览 0评论

折腾:

[已解决]运行Flask出错:socket.error Errno 98 Address already in use

之后,运行Flask,又出现其它错误:

(SIPEvents)  SIPEvents flask run –host=0.0.0. –port=8080
 * Serving Flask app “app”
 * Forcing debug mode on
Traceback (most recent call last):
  File “/root/Envs/SIPEvents/bin/flask”, line 11, in <module>
    sys.exit(main())
  File “/root/Envs/SIPEvents/lib/python2.7/site-packages/flask/cli.py”, line 478, in main
    cli.main(args=args, prog_name=name)
  File “/root/Envs/SIPEvents/lib/python2.7/site-packages/flask/cli.py”, line 345, in main
    return AppGroup.main(self, *args, **kwargs)
  File “/root/Envs/SIPEvents/lib/python2.7/site-packages/click/core.py”, line 696, in main
    rv = self.invoke(ctx)
  File “/root/Envs/SIPEvents/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File “/root/Envs/SIPEvents/lib/python2.7/site-packages/click/core.py”, line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File “/root/Envs/SIPEvents/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
    return callback(*args, **kwargs)
  File “/root/Envs/SIPEvents/lib/python2.7/site-packages/click/decorators.py”, line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File “/root/Envs/SIPEvents/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
    return callback(*args, **kwargs)
  File “/root/Envs/SIPEvents/lib/python2.7/site-packages/flask/cli.py”, line 403, in run_command
    use_debugger=debugger, threaded=with_threads)
  File “/root/Envs/SIPEvents/lib/python2.7/site-packages/werkzeug/serving.py”, line 677, in run_simple
    s.bind((hostname, port))
  File “/usr/local/lib/python2.7/socket.py”, line 228, in meth
    return getattr(self._sock,name)(*args)
socket.gaierror: [Errno -2] Name or service not known

flask socket.gaierror: [Errno -2] Name or service not known

flask socket.gaierror Errno -2 Name or service not known

退出SSH2连的CentOS服务器。

再进入试试。

果然就可以了:

(SIPEvents)  SIPEvents export FLASK_APP=app.py
(SIPEvents)  SIPEvents export FLASK_DEBUG=1
(SIPEvents)  SIPEvents flask run –host=0.0.0.0 –port=8080
 * Serving Flask app “app”
 * Forcing debug mode on
 * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger pin code: 353-795-063

转载请注明:在路上 » [已解决]Flask运行出错:socket.gaierror Errno -2 Name or service not known

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.188 seconds, using 22.16MB memory