How to run ng serve on port 80

Personally I wouldn't serve an Angular application in production using the Angular CLI (the ng serve command). A better option is to build the project (ng build) and serve the dist folder. Doing so you would have a much faster application as it wouldn't be "copiled on the fly" and it would't interact with the Angular CLI.

However if you'd like to stick with your approach, in order to run the application on a standard port (so that it hasn't to be specified; 80 for an HTTP website, 443 for an HTTPS one), you will have to modify a different file based on the Angular version you are using:

  • >= Angular 6:

    edit the angular.json file and in the serve object (under <yourProjectName> object), add this piece of code:

    "options": { "port": 80 }

  • Angular < 6.0:

    edit the angular-cli.json file and in the defaults object, add this piece of code:

    "serve": { "port": 80 }

Edit: If application is served using the ng serve --prod command, the following warning will be printed:

**************************************************************************************** 
This is a simple server for use in testing or debugging Angular applications locally. It hasn't been reviewed for security issues.

DON'T USE IT FOR PRODUCTION!
****************************************************************************************

I will assume that you are running your project in terminal. Try adding sudo before the ng serve, because port 80 needs to be run as root.