Angular 6+ How to change default port 4200

Due to a non accurate title: “angular-cli server – how to specify default port”, it was hard to find an answer to my question, but thanks to Vladymir Gonzalez I did.

To help others find the answer quickly, I extracted here the specific part for Angular 6, belonging to elwyn :

Update for @angular/cli@6.x: In the new angular.json you now specify a port per “project”

"projects": {
    "my-cool-project": {
        ... rest of project config omitted
        "architect": {
            "serve": {
                "options": {
                    "port": 4850    <-- add your custom port number here      
                }
            }
        }
    }
}

All options available:

https://github.com/angular/angular-cli/wiki/angular-workspace

Leave a Comment