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
I got this problem using Git Bash on Windows. I run npm start
, or node app.js
. After terminating it with Ctrl+C shortly and trying to start the server again using npm start
or node app.js
then I get this error message.
When I do this with the regular Windows Command Prompt, however, it works fine.
Or You can do it in another way. Open the Task Manager and Find the "Node.js:Server-side JavaScript" row. Select that and end task. It should work now.
Thanks.
I also encountered the same issue. The best way to resolve is (for windows):
Go to the Task Manager.
Scroll and find a task process named. Node.js: Server-side JavaScript
End this particular task.
There you go! Now do npm start and it will work as before!
Came from Google here with a solution for High Sierra.
Something changed in the networking setup of macos and some apps (including ping) cannot resolve localhost.
Editing /etc/hosts seems like a fix:
cmd: sudo nano /etc/hosts/
content 127.0.0.1 localhost
Or simply (if you're sure your /etc/hosts is empty)
sudo echo '127.0.0.1 localhost' > /etc/hosts
For windows users, you can use CurrPorts tool to kill ports under usage easily
Try opening the localhost in your browser. Just type: localhost:3000
in the address bar.
If the app opens-up, it means your previous npm run
is still active. Now, you can just make changes to the code and see the effects if you are designing the same app, or if you wanna run another app, just tweak the code (in index.js of previously running app) a little-bit and (probably refresh the browser tab) to make it crash ;)..... Now go run npm run start
again from your new app directory. Hope this helps! :)
or
You can open the Task Manager (WINDOWS_KEY+X > Task Manager) and you'll see the "Node.js:Server-side JavaScript" row. Select that and end task....It should work now!!
If not, change the .env
file of your app to include port:3002
and run the new app. This will allow you to run two separate apps on different ports. Cheers!!
if you are using webstorm just make sure your default port is not 3000 from file -> settings -> Build, Execution, Deployment -> Debugger And there change
Built-in server port
and set it to "63342" or see this answer Change WebStorm LiveEdit Port (63342)