react-router-tutorial icon indicating copy to clipboard operation
react-router-tutorial copied to clipboard

Lesson 10 / How to stop webpack server

Open youpiwaza opened this issue 8 years ago • 14 comments

https://github.com/reactjs/react-router-tutorial/tree/master/lessons/10-clean-urls

Hi there,

On this lesson, we have to reboot webpack dev server. But I killed it on console (using windows > cygwin) and when I lunched "npm start" I got an error for server already running.

I had a look on package.json and there are no other scripts ; Same thing for documentation of webpack, only one mention in comment when a guy had the same problem (on windows 10 too).

So I assume this will work if i reboot my computer, but it would be great to have the proper way to do that (didn't found a clear soft to kill in task manager x')).

Anyway thanks for your tutorials, they are great.

Ps : it's not a cygwin bug, website is still accessible & functionnal on localhost

youpiwaza avatar Sep 23 '16 15:09 youpiwaza

On my Mac when running this in the terminal I usually exit it with "Ctrl + C" command. I am not familiar of how this would work in Windows. It looks like they are discussing it in this Stackoverflow question https://superuser.com/questions/186670/is-there-ctrl-c-command-in-cygwin

Andersos avatar Oct 12 '16 20:10 Andersos

I have the same problem on Windows, but you don't need to reboot. You can open the Task Manager (WINDOWS_KEY+X > Task Manager) and you'll see the "Node.js:Server-side JavaScript" row. Click on it and then click the End Task button in the bottom-right corner of the TM window. Then you can return the Cygwin command line and start it fine. I don't know of a way to stop it from the command line, though.

drahmel avatar Dec 20 '16 19:12 drahmel

I have a similar problem, i was running react on port 3000, my terminal cleared everything before i got to stop the server now cannot start the server because i have something running on port 3000 it says i'm on a mac

tamakunay avatar Apr 19 '17 14:04 tamakunay

@Guyana345 Find: lsof -i :3000 Kill: kill -9 <PID>

Andersos avatar Apr 23 '17 13:04 Andersos

This is an issue with react-router, so I believe this issue should be close.

On a mac, Ctrl-C doesn't actually stops webpack, not for me at least ( @Andersos ), as this command would reveal:

ps aux | grep webpack

You can kill it with:

kill $(ps aux | grep 'webpack' | awk '{print $2}')

Izhaki avatar Jul 21 '17 23:07 Izhaki

If you're on windows using 'windows git' terminal this will do the trick. taskkill //PID $(netstat -ano | grep 8080 | awk '{print $5}') //F >/dev/null 2>&1

Mantisimo avatar Sep 09 '17 13:09 Mantisimo

Windows TLDR: 1: netstat -a -o -n (to get the PID) 2: taskkill /F /PID 12345 (Replace 12345 with your PID)

On windows machine I have same issue. Ctrl C seems to stop the server in command line, but then it is still running on Port 3000, etc.

If you go into command line and type netstat -a -o -n

This will show you all of the ports and process ids running.

The one you want is probably near the top of the list, and look under Local Address Column for row that matches your PORT: 0.0.0.0:3000 for port 3000 etc. Then on same row get the Process ID. This is the "PID" and then run this with your PID:

for example if PID is 15437 then

taskkill /F /PID 15437

Your PID will be unique and you need the first command to locate.

NickFoden avatar Sep 27 '17 20:09 NickFoden

Linux: killall -KILL node

uxiv avatar Oct 20 '17 06:10 uxiv

@youpiwaza if your issue is solved you can close this issue.

Andersos avatar Feb 02 '18 11:02 Andersos

i had the same issue on windows solved it using the commands below remember these commands will only work in cmd not in gitbash this command will give you the process id of the process running on that specific port

$ netstat -ano | find ":3000 "

this command will tell you which program is using this port

$ tasklist /fi "pid eq {process-id}"

and this will kill that process

$ taskkill /pid {process-id} /f

Awais-cb avatar Oct 27 '18 19:10 Awais-cb

or you can simply run task manager and kill node's process

Awais-cb avatar Oct 27 '18 19:10 Awais-cb

with one app running: kill $(lsof -i :4000 | grep node | awk '{print $2}')

defusioner avatar Mar 07 '19 14:03 defusioner

kill $(lsof -t -i:3000,3001) // 3000 and 3001 are ports to be freed

abhijithqb avatar Mar 12 '19 09:03 abhijithqb

For me this command does not work on Windows 10 in Cygwin:

$ kill -9 15916
bash: kill: (15916) - No such process

Instead of it you can use next commands:

$ netstat -ano | grep ':8080' | awk '{print $5}' | xargs powershell kill -f
$ netstat -ano | grep ':8080' | awk '{print $5}' | while read pid; do powershell kill -f $pid; done;
$ netstat -ano | grep ':8080' | awk '{sub(/\r/,"",$5) ; print $5}' | while read pid; do taskkill /F /PID $pid; done;
SUCCESS: The process with PID 15916 has been terminated.

popovserhii avatar Apr 10 '19 06:04 popovserhii