I have a simple server running in node.js using connect:
var server = require('connect').createServer();
//actions...
server.listen(3000);
In my code I have actual route handlers, but that's the basic idea. The error I keep getting is:
EADDRINUSE, Address already in use
I receive this error when running my application again after it previously crashed or errors. Since I am not opening a new instance of terminal I close out the process with ctrl + z
.
I am fairly certain all I have to do is close out the server or connection. I tried calling server.close()
in process.on('exit', ...);
with no luck.
Ctrl + z
you should useCtrl + c
which will close the program correctly by sending SIGQUIT :) See the wiki for further details :) – Mammalogyserver.close()
for previuos servers – Personifypkill nodejs
orpkill node
if on UNIX-like OS – Flaviaflavianctrl + c
to close the program. But if you already didctrl + z
, you can usefg
to focus on the program again, or usebg
to let it resume in the background. Here is a better explanation: superuser.com/a/169057 – Establishmentlsof -nP -iTCP -sTCP:LISTEN | grep <port>
. And thenkill -9 <pid>
– Zuleika