Flask 运行问题:socket.error:[Errno 98] 地址已在使用中

Asa*_*hel 1 python sockets flask flask-login sublimetext3

如果我在 sublime text 或 PyCharm 中运行 Flask,我收到此错误消息sublime issue ( My OS: Ubuntu 16.04) "socket.error: [Errno 98] Address already in use"。但是如果我在我的 Ubuntu终端上运行 Flask ,它正在运行。我知道该端口使用了另一项服务。然后我试图从 google/stackoverflow 解决这个问题。

# ps ax | grep 5000 // or # ps ax | grep name_of_service

# kill 3750            // or # killall name_of_service
Run Code Online (Sandbox Code Playgroud)

但什么都没有改变。只有当我尝试在 sublime 或 pycharm IDE 上运行时才发现这个问题。

vij*_*hya 6

简单的方法是使用 fuser。

fuser <yourport>/tcp #this will fetch the process/service
Run Code Online (Sandbox Code Playgroud)

替换<yourport>为您要使用的端口

#to kill the process using <yourport> add `-k` argument 
fuser <yourport>/tcp -k 
Run Code Online (Sandbox Code Playgroud)

在你的情况下

fuser 5000/tcp -k
Run Code Online (Sandbox Code Playgroud)

现在您可以使用该端口运行烧瓶。