admin管理员组文章数量:1654257
I want to run a single python flask hello world. I deploy to App Engine, but it’s showing like it’s saying that the port is in use and it looks like it’s running on multiple instances/threads/clones concurrently.
This is my main.py
from flask import Flask
app = Flask(__name__)
@app.route('/hello')
def helloIndex():
print("Hello world log console")
return 'Hello World from Python Flask!'
app.run(host='0.0.0.0', port=4444)
And this is the logs that I got:
* Serving Flask app 'main'
* Debug mode: off
Address already in use
Port 4444 is in use by another program. Either identify and stop that program, or start the server with a different port.
[2022-08-10 15:57:28 +0000] [1058] [INFO] Worker exiting (pid: 1058)
[2022-08-10 15:57:29 +0000] [1059] [INFO] Booting worker with pid: 1059
[2022-08-10 15:57:29 +0000] [1060] [INFO] Booting worker with pid: 1060
[2022-08-10 15:57:29 +0000] [1061] [INFO] Booting worker with pid: 1061
It says that Port 4444 is in use. Initially I tried 5000 (flask’s default port) but it says it’s in use. Also I tried removing the port=4444 but now it’s saying Port 5000 is in use by another program, I guess flask by default assign port=5000. I’m suspecting that it’s because GAE is running in multiple instances that’s causing this error. If not, then please help to solve this issue.
I solved using lsof and kill commands. In my case, error message mentioned port 5000 so I first checked which processes(s) are using port 5000 by calling lsof -i:5000 in the terminal. Once I located the PID of already running Flask application, I killed it using this command: kill -9 and voilà!
This approach should work for both mac and Linux users. If Windows users can find the equivalent of the lsof and kill Linux commands, it may work there as well.
简单总结下:当运行程序显示某个端口被占用时,可以使用lsof 命令 -i:xxxx产看占用端口的程序,之后使用kill ,关闭程序即可。
lsof 安装:
apt-get install lsof
本文标签: programXXXXPORTidentifyServer
版权声明:本文标题:Port XXXX is in use by another program. Either identify and stop that program, or start the server w 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1729650518a1208984.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论