I'm using nodemon to run my Express server in development and auto-restart my process whenever a file changes. When it restarts, it frequently errors with "Port 3000 is already in use".
Killing nodemon, running killall node
, and then restarting nodemon fixes it temporarily. But I want to fix it properly, and make sure the port gets released every time the app gets killed.
I've tried using signal-exit to manually call server.close()
as a cleanup job:
const onExit = require('signal-exit')
onExit(() => {
server.close();
});
But that doesn't work either. It still frequently fails to release the port. Any ideas?
via callum
No comments:
Post a Comment