156

I've been doing web development with Angular2 and have been using both Angular2 and Firebase to run local servers. I haven't been able to find a command similar to typing quit when using Ionic to create a server, so I have to close the terminal tab each time. Is there a way to end the server and get my terminal tab back?

Thanks.

Ayman Nedjmeddine
  • 11,521
  • 1
  • 20
  • 31
aheigins
  • 2,574
  • 3
  • 19
  • 26

14 Answers14

255

You can use the following command to end an ongoing process:

ctrl + c

Jonathan
  • 2,700
  • 4
  • 23
  • 41
stijn.aerts
  • 6,026
  • 5
  • 30
  • 46
  • 16
    I have ng serve running in a console window, and it just is not responding to ctrl+c at all. – Shawn de Wet Feb 04 '17 at 07:45
  • 1
    In case of using IntelliJ, pay attention to open the first console u used, ng is still running there, you might have multiple console tabs opened – Adir Dayan Oct 27 '20 at 17:55
  • @ShawndeWet: same here, on Windows 10 with angular 10.x.x; however, it seems to take a minute or 2 to respond. Pressed CTRL+C and 2 minutes later I had the "abort batch process (y/N)" prompt. Edit: pressing ctrl+c multiple times doesn't seem to reduce this time. – user1931751 Feb 02 '21 at 16:03
38

Try using ctrl + c twice to get the prompt for terminating the batch job.

André Kool
  • 4,880
  • 12
  • 34
  • 44
Paulo Cunha
  • 391
  • 3
  • 5
38

I was able to stop via this on Windows for Angular 8:

Step 1: Find 4200 process

netstat -ano | findstr :4200

Step 2: Kill that process:

taskkill /PID <PID> /F

enter image description here

Raghav
  • 8,772
  • 6
  • 82
  • 106
37

If you cannot see the "ng serve" command running, then you can do the following on Mac OSX (This should work on any Linux and Uni software as well).

ps -ef | grep "ng serve"

From this, find out the PID of the process and then kill it with the following command.

kill -9 <PID>
Partha
  • 401
  • 4
  • 6
  • 3
    Thanks you that helped me. If you are on Windows, just open the task manager and kill the node.exe process. Hope this will help – Yacino Jan 25 '19 at 10:54
  • taskkill /F /IM node.exe (Careful: this force closes all instances of node.exe on Windows) – kirodge May 09 '19 at 09:08
  • thanks for this. this is what i needed since my app was still running even after shutting down webstorm – gdubs May 12 '21 at 07:45
23

If ctrl + c doesn't work use this:

ctrl +shift+ c

Sometimes people change the behaviour of ctrl + c for copy/pasting so you may need this.

Of course, you should also ensure that the terminal window has keyboard focus, ctrl + c won't work if your browser window has focus.

Ben Taliadoros
  • 7,003
  • 15
  • 60
  • 97
11

ctrl + c OR ctrl + Pause/Break

Both will ask for Terminate batch job, then press Y or y and click enter.

Developer Guy
  • 2,318
  • 6
  • 19
  • 37
Vishwa G
  • 573
  • 1
  • 6
  • 13
4

for stop angular project press Ctrl+C twice , then press Y , then press Enter

AEM
  • 1,354
  • 8
  • 20
  • 30
M Komaei
  • 7,006
  • 2
  • 28
  • 34
2

With Windows 10 / Powershell ctrl + c did not work; Powershell tried to gracefully stop the app.

Used normal cmd and had no issues stopping the ng serve with ctrl + c.

Caltor
  • 2,538
  • 1
  • 27
  • 55
Witold Kaczurba
  • 9,845
  • 3
  • 58
  • 67
2

Can use

killall -9 

The killall command can be used to send a signal to a particular process by using its name. It means if you have five versions of the same program running, the killall command will kill all five.

Or you can use

pgrep "ng serve"

which will find the process id of ng and then you can use following command.

kill -9 <process_id>
Pooja Khatri
  • 550
  • 5
  • 11
0

it is enough to modify something in your text editor and reload localhost. all your connection will be lost nd you have opsibility to ng serve the new project in the console.

0

I was trying to run this from within the Visual Studio 2017 Package Manager Console. None of the above suggestions worked.

See this link where Microsoft states "The solution is not to use package manager for angular development, but instead use powershell command line. ".

Andy Thomas
  • 1,367
  • 2
  • 14
  • 30
-2

----Ctrl + c then choose Y from the Y/N option provided.

Hedego
  • 276
  • 2
  • 12
  • This answer duplicates existing answers and adds nothing new. In fact is also lacks better formatting present in other previous answers. – Caltor Feb 03 '20 at 15:28
-2

Exit the IDE and boots up IDE again , try it.

  • Welcome to StackOverFlow you can check the link [How To Answer](https://stackoverflow.com/help/how-to-answer) so your answers will help more people – Sylhare Oct 08 '19 at 12:19
  • 1
    Only relevant if you are running ng serve inside the IDE terminal – Caltor Feb 03 '20 at 15:26
-3

On macOS Mojave 10.14.4, you can also try Command ⌘ + Q in a terminal.

iBug
  • 35,554
  • 7
  • 89
  • 134