python Pylons:尝试服务时地址已在使用中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1071071/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pylons: address already in use when trying to serve
提问by resopollution
I'm running pylons and I did this: paster server development.ini It's running on :5000
我正在运行 pylons,我这样做了:paster server development.ini 它在 :5000 上运行
But when I try to run the command again: paster serve development.ini
但是当我再次尝试运行命令时: paste serve development.ini
I get this message: socket.error: [Errno 98] Address already in use
我收到此消息:socket.error: [Errno 98] 地址已在使用中
Any ideas?
有任何想法吗?
采纳答案by Lennart Regebro
Normally that means it's still running, but that should only happen if it's in daemon mode. After you started it, do you get a command prompt, or do you have to stop it with Ctrl-C?
通常这意味着它仍在运行,但只有在它处于守护程序模式时才会发生这种情况。启动后,您是否会收到命令提示符,还是必须使用 Ctrl-C 停止它?
If you get a command prompt back it's deamon mode and you have to stop it with
如果你得到一个命令提示符,它是守护模式,你必须用
paster server development.ini stop
If you have stopped it with Ctrl-C (and not Ctrl-Z of course), I have no idea.
如果您使用 Ctrl-C(当然不是 Ctrl-Z)停止它,我不知道。
回答by therealmarv
I've found this trick in a forum:
我在论坛上发现了这个技巧:
This will kill all programs listening to port 5000
这将杀死所有侦听端口 5000 的程序
kill -9 `fuser -n tcp 5000`
回答by Grzegorz Oledzki
As I understand your question, you start some application to listen on port 5000. Then without stopping it (?), you try to start another instance to listen on het same port? If so, you won't succeed.
我理解你的问题,你启动了一些应用程序来监听端口 5000。然后没有停止它(?),你尝试启动另一个实例来监听同一个端口?如果是这样,你就不会成功。
You can always check what application is listening on what port number by using netstat
(for both Windows and UNIX-like systems, I have no experience with others).
您始终可以通过使用来检查哪个应用程序正在侦听哪个端口号netstat
(对于 Windows 和类 UNIX 系统,我没有其他人的经验)。
回答by Cerin
This has also happened to me when the server died unexpectedly, and didn't close it's socket's properly. Essentially, the socket is still listed as open with the operating system, even though the process has died. I've found if I wait for 30-60 seconds, the OS will realize the associated process has died, and cleanup the sockets automatically.
当服务器意外死亡并且没有正确关闭它的套接字时,这也发生在我身上。本质上,即使进程已终止,套接字仍被列为操作系统打开。我发现如果我等待 30-60 秒,操作系统会意识到关联的进程已经死亡,并自动清理套接字。
回答by andyshi
your default port 8080 is using. you should add '-p 10000' after command to take port 10000
您的默认端口 8080 正在使用。您应该在命令后添加“-p 10000”以获取端口 10000
回答by user2348608
naturally netstat
(netstat -an | grep 5000
does the trick on linux). Will grab the port
自然netstat
(netstat -an | grep 5000
在 linux 上做的伎俩)。会抢端口
However I found this other question with the same error.
但是我发现另一个问题也有同样的错误。
Python [Errno 98] Address already in use
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Essentially Python takes too long to open the socket.
本质上,Python 需要很长时间才能打开套接字。
回答by Avinash Raj
I tried all the upvoted answers exists here but no one works for me. But this below command does the trick.
我尝试了这里存在的所有赞成的答案,但没有人适合我。但是下面的这个命令可以解决问题。
sudo kill $(sudo lsof -t -i:5000)
This would kill the process which listens on the port 5000
.
这将终止侦听端口的进程5000
。