How to stop Node.js server?

44,593

Solution 1

At first: CTRL+Z will terminate the execution. Later, in order to terminate the PID(processID), follow the following.

The generalised approach for kill any processId including localserver:

Reference: https://stackoverflow.com/a/57536823/8119511

For this case:

$:lsof -i tcp:<PORT>

It will bring you out with the PID(processId) associated with port:

$:kill -9 <process-id>

And again, you can runserver.

Solution 2

You can stop the server by killing the process. In Windows, run CMD and type taskkill /F /IM node.exe This will kill(stop) all Node.js processes. And then you can restart it.

Share:
44,593
Alanay
Author by

Alanay

Updated on September 23, 2021

Comments

  • Alanay
    Alanay over 2 years

    I've just setup MEAN stack on my DigitalOcean server. I got the test app to run fine, but now when I open command line from DigitalOcean it just shows info: GET /modules/etc... and the part where I type is blank. How do I stop the server and get it back to where it was originally so I can access folders etc.?

    Simply doing CTRL+C does not stop the server from running, which is what I need to do.