how to run angular cli on ec2 instance ng serve not working

Solution for error

Provided host xx.xx.xx.xx could NOT be bound. Please provide a different host address or hostname

If you run ng serve without giving correct port & correct public DNS you may get above error.

For any new developer hosting Angular application on AWS EC2 instance can be confusing some time.  Running ng serve starts the server but still your applicatoin is not running.

You need to check few thins in your EC2 instance

1. First check that port 4200 or any port that you want to use for Angular is added in security group to accept the traffic.

2. After allowing the port run ng serve with correct domain name or Public DNS shown in EC2 Instance for example "ec2-xx-xx-xx-xx.eu-west-1.compute.amazonaws.com"

 

Add On:

If you are getting this error with localhost:4200 you can try ng serve --host 0.0.0.0

To add specific port you can execute the command as follows: ng serve --host 0.0.0.0 -- port 4200

Comments

No Comments Posted Yet (Be The First To Comment On This)

Please share your views with us
Check if you want to display your email-id.
Enter the sum of digits
8+7 =