skip to Main Content

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

enter image description here

2

Answers


  1. 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

    Login or Signup to reply.
  2. 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:

    1. Check Security Group:

    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.

    1. Application Configuration:

    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.

    1. Port Access:

    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&gt;:4200.

    1. Production Deployment:

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search