I have created a windows EC2 instance and i started my Angular project with command ng serve –host=0.0.0.0 –disable-host-check and i am able to access my application inside EC2 instance. I have set inbound rule in security group as All traffic. Still i am unable to access the application from Public IPv4 address. Any idea what am i missing. The application is running on default port 4200
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
2
Answers
For accessing your application using the public IP address you will need your application to run on port 80.
If you want to access your application on port 4200 specify the port number with your IP address in your browser. For example, if your public IP is 192.168.1.1 then use – http://192.168.1.1:4200
There can be a couple of reasons why you can’t access your Angular application on an EC2 instance using the public IP address. Here are some steps to troubleshoot:
Ensure your EC2 security group has an inbound rule allowing traffic on the port your Angular application is running on. By default, Angular runs on port 4200. If you want to access it on port 80 (standard web port), you’ll need a rule for port 80.
The rule’s source should be set to "0.0.0.0/0" to allow traffic from anywhere.
When running your Angular application on the EC2 instance, use the ng serve command with the following flags:
–host 0.0.0.0: This allows the application to listen on all interfaces (not just localhost).
(Optional) –port 80: If you want to access the application on port 80 instead of 4200.
If your application is running on port 4200, you’ll need to specify the port number in your browser address bar when accessing it using the public IP. For example, http://<public_ip>:4200.
Consider that ng serve is for development. In production, it’s recommended to build the Angular application for deployment and serve it using a web server like Nginx or Apache.