How to Run Angular App on Different Host?

Today, run angular app in different host is our main topic. Here you will learn ng serve –host 0.0.0.0. We will use how to change host number in angular. I explained simply about how to change host number in angular. Here, Creating a basic example of how to run angular app on different host.

If you want to run your angular app on a different host then I will show two ways to change host in the angular app. You can use this solution with angular 8, angular 9, angular 10, angular 11, angular 12 and angular 13 versions.

Let’s see below solution:

Solution 1:

You can define direct host with ng server command, let’s run below command:

ng serve --host 0.0.0.0

Now, go to your browser and open the below link.

http://0.0.0.0:4200

Solution 2:

You can configure default host in angular.json file, let’s run below command:

angular.json

.medrectangle-4-multi-155{border:none!important;display:block!important;float:none;line-height:0;margin-bottom:15px!important;margin-left:0!important;margin-right:0!important;margin-top:15px!important;max-width:100%!important;min-height:250px;min-width:300px;padding:0;text-align:center!important}

"projects": {

"my-project-name": {

... extra configurations

"architect": {

"serve": {

"options": {

"host": "0.0.0.0"

}

}

}

}

}

let’s run app:

ng serve

Now, go to your browser and open the below link.

http://0.0.0.0:4200

I hope it can help you…

Leave a Comment