I'd like to restart one of many Node.js processes I have running on my server. If I run ps ax | grep node
I get a list of all my Node proccesses but it doesn't tell me which port they're on. How do I kill the one running on port 3000 (for instance). What is a good way to manage multiple Node processes?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- How to reimport module with ES6 import
- Why is `node.js` dying when called from inside pyt
- How to verify laravel passport api token in node /
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
- Get file created date in node
This saved me a lot of time:
pkill node
Why not a simple
fuser
based solution?If you don't care about whether the process using port 3000 is node, it could be as simple as
If you wan't to be sure you don't kill other processes, you could go with something like
If you run:
You should see something like:
In this case the
5902
is the pid. You can use something like this to kill it:Here is an alternative version using
egrep
which may be a little better because it searches specifically for the string 'node':You can turn the above into a script or place the following in your
~/.bashrc
:and now you can run:
A one-liner is
You only need the sudo if you are killing a process your user didn't start. If your user started the node process, you can probably kill it w/o sudo.
Good luck!