0

I had change the default localhost 4200 to localhost 4202 by using ng serve --host 0.0.0.0 --port 4202

and It works but once the session terminate the localhost automatically divert to localhost 4200. I have to again run the command to change port.

Is this the right way to change the Port or I can Change it permanently for a project.

N.D
  • 1
  • 2
  • check this link https://stackoverflow.com/questions/40717449/how-to-change-angular-2-port-from-4200-to-any-other – Prithivi Raj Nov 20 '17 at 10:24
  • 2
    Possible duplicate of [How to change angular 2 port from 4200 to any other](https://stackoverflow.com/questions/40717449/how-to-change-angular-2-port-from-4200-to-any-other) – Prithivi Raj Nov 20 '17 at 10:25
  • I checked the link , I can done by doing change in angular-cli.json file but i want to know that Is this command ng serve –host 0.0.0.0 –port 4202 is not a permanent solution. I have to run this command again and again to run the project on 4202 port. – N.D Nov 20 '17 at 10:45
  • Have you tried this in the same link -- Goto nodel_modules/angular-cli/commands/server.js Search for var defaultPort = process.env.PORT || 4200; and change 4200 to anything else you want. – Prithivi Raj Nov 20 '17 at 10:51
  • I have already change my localhost successfully by making change in angular-cli.json file . I am just asking for the command , Is by running ng serve –host 0.0.0.0 –port 4202 command is permanent solution or not ?? – N.D Nov 20 '17 at 10:56
  • default port will be always 4200 until you do some changes in server.js file or angular-cli.json file. running command with port number is just a temporary workaround. – Prithivi Raj Nov 20 '17 at 11:06
  • thanks for the reply.. – N.D Nov 20 '17 at 12:07

0 Answers0