Umair Jameel
Umair Jameel

Reputation: 1673

Change localhost:4200 to something mysite:4200 in Angular 5

I want to change host name for testing purpose. I have tried ng serve --host 0.0.0.0 but app again runs on localhost:4200. Is there a way that app runs on different host name (word) in browser?

Upvotes: 3

Views: 12947

Answers (2)

Vitach
Vitach

Reputation: 291

  1. Add the next row to the end of your hosts file: 127.0.0.1 my.local.host
  2. Start app: ng serve --host "my.local.host"

Upvotes: 6

Randy
Randy

Reputation: 4391

If you're on Mac or Linux and just for local testing, you can edit /etc/hosts and add your own dns mapping. I'm sure you can do something similar on Windows.

For example you can add adding mysite to your hosts file:

127.0.0.1       mysite

Then you can access your app by going to http://mysite:4200.

Note that if making changes to your hosts file don't appear to work you may need to either reboot or make your OS reload your hosts file. See the bottom of this page for more information: https://www.imore.com/how-edit-your-macs-hosts-file-and-why-you-would-want

Upvotes: 7

Related Questions