15

I was wondering if it is possible to work on two Angular(2) projects at the same time. I open my first project using ng serve and it runs on the server and when I save it it updates. But of coarse when I try to open another project with ng serve it will tell you that "port:4200 is already in use". Is there a way to open a project on a different port?

Seeing that this is a virtual server, I can not think that just giving it another port number can be to difficult. I do not want to log out of the one project the whole time, and then into the second one and back again after changing just one line to see if it works.

Regards

3 Answers 3

37

Open 2nd project then run this command:

ng serve --port 4210

Change port as you want, then open browser: localhost:[port]

Following this section:

https://github.com/angular/angular-cli#generating-and-serving-an-angular-project-via-a-development-server

Sign up to request clarification or add additional context in comments.

4 Comments

Hi Tiep, do I run this for the second project after running ng serve normally for the first project? And then just open localhost:4210 in browser for second project? Are the port numbers specific or can I use any numbers, just for clarity?
Ah ok, got the answers from the links... Thanks allot!!
use any unuse port: > 1024, because almost port from 1 -1024 are use by some service: 80 -> http. 443 -> https, 21 -> ssh, ... angular cli by default using port 4200
That works fine. Thanks. Better find open ports first and assign it.
6

If you're using angular-cli, It is pretty easy :

In console run :

ng serve --host 0.0.0.0 --port 4201 --live-reload-port 4915

For reference : https://github.com/angular/angular-cli

Comments

1

Open Seconde terminal in vsCode

ng serve --port 4210

Change port number as you want, then open browser: localhost:[port]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.