Reputation: 39
I am facing issues while accessing an Angular 6 application using public IP through internet. What I did was, I started a windows EC2 instance. After that installed nodejs and angular cli as below-
npm install -g @angular/cli
Then created a new angular application as below
ng new my-app
After starting the angular application my-app with the below command
ng serve //Configured port 80
I can access this within the windows EC2 instance and my browser in EC2 instance shows the angular application up and running however, I am not able to access from outside i.e from my local machine browser. If I put the public IP address in browser I cannot access.Though the port 80 is set as inbound rules but still it says
This site can’t be reached ec2-13-233-140-16.ap-south-1.compute.amazonaws.com refused to connect.
I am doing this in Mumbai region so latency should not be the issue.
I tried this with Ubuntu instance still the same problem.
Need some valuable suggestion.
Thanks
Sachin
Upvotes: 1
Views: 1761
Reputation: 39
Ok now I am able to make it work but with a Ubuntu instance.What I did was create an Ubuntu instance in Mumbai region and created a new application with command ng new my-app and then started the server with the command ng serve --host 0.0.0.0 --port 80 and I am able to browse my application with the public IP on port 80 and also tried with 4200 port and works. Not sure why it was not working with windows instance .I still don't have an answer to it but with Ubuntu it works ! Yes it works. I am glad that it works. Will try to work with windows instance. Would also like to say thanks a lot to every one for their help.
Upvotes: 1
Reputation: 18301
Make sure you use the following command
ng serve --host 0.0.0.0 --port 80
This will ensure that it listens on addresses other than localhost
Upvotes: 1