How to change angular port from 4200 to any other
It seems things have changed in recent versions of the CLI (I'm using 6.0.1
). I was able to change the default port used by ng serve
by adding a port
option to my project's angular.json
:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"projects": {
"my-project": {
"architect": {
"serve": {
"options": {
"port": 4201
}
}
}
}
}
}
(Only relevant properties are shown in this example.)
The solution worked for me was
ng serve --port 4401
(You can change 4401 to whatever number you want)
Then launch browser -> http://localhost:4401/
Basically, I was having two Applications and with the help of the above approach now I am able to run both of them simultaneously in my development environment.