I am learning angular 2 and for the first time I am using the angular CLI project to create a sandbox project.
I was able to run the command \"ng serve\" and it wor
you can use fuser -k 4200/tcp if it is Linux Operating system
Instead of killing the whole process or using ctrl+z
, you can simply use ctrl+c
to stop the server and can happily use ng serve command
without any errors
or if you want to run on a different port simply use this command ng serve --port portno(ex: ng serve --port 4201)
.
When you use Ctrl+Z
, you are going to suspend a running task but not to kill it. You can later use command fg
to resume the task.
If you want to quit ng serve
, you should use Ctrl+C
instead, in which will also release the 4200 port.
If you compiling your angular JS code in both CMD and IDE then this issue occur. In CMD, your angular JS code compile automatically whenever you change your angular JS code in IDE and then your IDE want to occupy the same port i.e 4200 which is occupied by CMD already So, there is a simple solution for this issue, just close your cmd while compiling your code in IDE.
Use this command to kill ng:
pkill -9 ng
For Windows:
Open Command Prompt and
type: netstat -a -o -n
Find the PID of the process that you want to kill.
Type: taskkill /F /PID 16876
This one 16876 - is the PID for the process that I want to kill - in that case, the process is 4200 - check the attached file.you can give any port number.
Now, Type : ng serve
to start your angular app at the same port 4200