Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to kill a nodejs process in Linux?

tcp    0     0 0.0.0.0:80     0.0.0.0:*     LISTEN      9631/node     

How do I kill this process in linux(ubuntu)?

like image 401
LeBlaireau Avatar asked Jul 27 '15 09:07

LeBlaireau


People also ask

How do you stop a node JS process?

Method 1: Using ctrl+C key: When running a program of NodeJS in the console, you can close it with ctrl+C directly from the console with changing the code shown below: Method 2: Using process. exit() Function: This function tells Node. js to end the process which is running at the same time with an exit code.

How do I kill a node JS application?

Ctrl + C will actually kill it.

How do I stop all node processes in Linux?

Linux machine: process. exit() in your application causes the NodeJS instance to close. killall node in bash would kill all NodeJS instances running on your machine.


2 Answers

pkill is the easiest command line utility

pkill -f node 

or

pkill -f nodejs 

whatever name the process runs as for your os

—- update —- It has been raised that this does not address killing a single node process and instead kills EVERY node process. If this is desired pkill is your tool, otherwise use one of the other accepted answers

like image 52
vbranden Avatar answered Sep 25 '22 05:09

vbranden


sudo netstat -lpn |grep :'3000' 

3000 is port i was looking for, After first command you will have Process ID for that port

kill -9 1192 

in my case 1192 was process Id of process running on 3000 PORT use -9 for Force kill the process

like image 40
Krunal Limbad Avatar answered Sep 23 '22 05:09

Krunal Limbad