“Port 4200 is already in use” when running the ng serve command

后端 未结 30 1389
深忆病人
深忆病人 2020-12-02 03:47

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

相关标签:
30条回答
  • With ctrl + z you put the program in the background. On Linux you can get the session back in the foreground with the following command:

    fg ng serve

    You don't need to kill the process.

    0 讨论(0)
  • 2020-12-02 04:23

    We can forcefully kill the port by following command.

    kill -2 $(lsof -t -i:4200)
    
    0 讨论(0)
  • 2020-12-02 04:23

    Just restart the IDE you are using, then it will work.

    0 讨论(0)
  • 2020-12-02 04:24

    In my case none of the above mentioned worked.

    UBUNTU 18.04 VERSION

    Below command worked.

    sudo kill -9 $(lsof -i tcp:4200 -t)
    
    0 讨论(0)
  • 2020-12-02 04:25

    If you are using VSCode, you have the option to kill terminal and add a new terminal. Close the tab and open a new tab. It worked for me.

    Edited: Use ctrl+c and press y. With out killing terminal also, You can proceed. If you want to open a new instance of visual studio and run a different application , you can use ng serve --port 4401.

    0 讨论(0)
  • 2020-12-02 04:28

    Not ctrl+Z, you must run for stop ctrl+C

    0 讨论(0)
提交回复
热议问题