I have created a node application and run it in 3000 port. Now I need to stop/start/restart this application by using command prompt. How can I do it.
Asked
Active
Viewed 1.1k times
2
-
Possible duplicate of [How do I get started with Node.js](http://stackoverflow.com/questions/2353818/how-do-i-get-started-with-node-js) – Tim Ogilvy Mar 16 '16 at 04:26
-
Possibly related: [node.js as a background service](http://stackoverflow.com/questions/4018154/node-js-as-a-background-service) – Jonathan Lonowski Mar 16 '16 at 04:41
-
In general... Start: execute `node entryScript.js` – Stop: [`[Ctrl]+[c]`](http://stackoverflow.com/questions/6108953/how-does-ctrl-c-terminate-a-child-process) – Jonathan Lonowski Mar 16 '16 at 04:42
3 Answers
5
Start:node app.js
Stop:Ctrl + C
Restart:node app.js
Better option try Nodemon. Nodemon is a utility that will monitor for any changes in your source and automatically restart your server.
Install nodemon globally
npm install nodemon -g
Run the server
nodemon app.js

Nivesh
- 2,573
- 1
- 20
- 28
-
yes but in my server multiple node application is running. How I can stop a particular app running on 3000 port – Rasmikant Mar 16 '16 at 06:53
2
Assuming you are using linux If you need to stop some application running on some specific port use this and you know the port but not the process id. find the process id like this
netstat -plten | grep LISTEN | grep 3000
this will output some thing like this
tcp 0 0 :::10060 :::* LISTEN 0 20465 3489/node
where 3489 is the process id.
then do
kill -9 3489
to kill the procees

Mustafa Mamun
- 2,591
- 2
- 14
- 17
-
-
okk Then do this netstat -aon | find /i "3000" and then the answer is TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 9348 TCP [::]:3000 [::]:0 LISTENING 9348 Then do Taskkill /PID 9348 /F – Mustafa Mamun Mar 16 '16 at 09:20
-
Thanks it works for me. How to kill all node process using this taskkill command – Rasmikant Mar 16 '16 at 09:32
-
1
-
write tasklist in the cmd and check if any node program is running or not. And this will give you all the pid of the processes so you can kill them one by one also – Mustafa Mamun Mar 16 '16 at 09:52
-
The tasklist command is showing all running tasks. How to know which are node app processes. – Rasmikant Mar 17 '16 at 06:21
-
1all the node processes should be defined by node.exe in the left most collumn. and I think you do not have any node process running on your system as taskkill /F /IM node.exe command is saying process node.exe not found – Mustafa Mamun Mar 17 '16 at 07:53
1
You can simply press 'Ctrl + C' to stop any process in cmd. Also consider using nodemon , its a fantastic tool which automatically restarts your app whenever you save any new changes to the files.

Ankur Rana
- 88
- 9