I have been working with a node.js project for a few weeks and it has been working great. Usually, I use npm start
to run my app and view it in a browser on loc
For windows user, Just simple stop all processes of Node.js in Task Manager
Hope it will help
In package.json scripts inlcude:
"start": "nodemon app.js --delay 1500ms"
I believe the issue was for me the time that the old port was not shutting down in time by nodemon for the restart. I experienced the issue using multer.
check for any process running on the same port by entering the command:
sudo ps -ef
You can find the process running on the respective node port, then kill the node by
kill -9 <node id>
If the problem still remains then just kill all the node
killall node
In my circumstance I had just started using VS Code and had followed a tutorial using Sequelize. In the end I had a bin/www file that had the listen() in there. I didn't know about this and I was running my app by running node app.js, when it didn't work I then added in the express server stuff with .listen() (which worked fine).
But when starting to use nodemon and VSCode it was pointed at bin/www and that required my app.js.
Long story short I had added .listen() to my app.js and was running app.js directly when I should have not added that and run bin/www.
Simple in linux
server or app listen() methods might be added at 2 places. Search for listen() methods in the for the application startups thats why its returning as Server started at Port XXXX and Port XXXX already in use message coming side by side