「Python」Linux环境下启动Flask应用时失败,Error:Address already in use
程序员文章站
2022-07-13 14:25:49
...
记录个小问题
错误如下:
* Serving Flask app "hello" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
Traceback (most recent call last):
File "hello.py", line 10, in <module>
app.run( host='0.0.0.0' )
File "/root/ray/lib/python3.5/site-packages/flask/app.py", line 943, in run
run_simple(host, port, self, **options)
File "/root/ray/lib/python3.5/site-packages/werkzeug/serving.py", line 814, in run_simple
inner()
File "/root/ray/lib/python3.5/site-packages/werkzeug/serving.py", line 774, in inner
fd=fd)
File "/root/ray/lib/python3.5/site-packages/werkzeug/serving.py", line 660, in make_server
passthrough_errors, ssl_context, fd=fd)
File "/root/ray/lib/python3.5/site-packages/werkzeug/serving.py", line 577, in __init__
self.address_family), handler)
File "/usr/local/python3/lib/python3.5/socketserver.py", line 443, in __init__
self.server_bind()
File "/usr/local/python3/lib/python3.5/http/server.py", line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/local/python3/lib/python3.5/socketserver.py", line 457, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
提示说地址被占用。
输入命令:
jobs -l
原来,有个应用并没有关闭
再输入一下命令:
kill %n (n代表你的flask应用序号)
完成以上操作可以重新开启应用了。
上一篇: poi设置一个单元格中文字不同的样式