amazon-web-servicesamazon-ec2aws-security-group

HTTP Connection refused to AWS EC2 instance


I'm trying to make a login HTTP request from the frontend (Angular app) to AWS EC2 instance but it ends up with (ERR_CONNECTION_REFUSED) error.

This would be probably a security group policy issue (from the internet) but correct me if I'm wrong. It was working perfectly before and got this error in a few days. If anyone can help me solve this problem.

I tried to resolve this issue by configuring security group inbound rules with specific port number but port textbox will be disabled when I select HTTP request type. I added a snap of it. Kindly correct me if I'm wrong in detecting the problem so I can make a solution for it.

enter image description here


Solution

  • It can also be due to the service not listening on the port that you are trying to connect to or not started or present. May be if the server running on the AWS instance if listening (and serving) to localhost or 127.0.0.1 / interface can also ignore connections from outside in which case it should be ensured the service listens on the appropriate external address.

    AWS also checks to detect abuse. If somehow, some unknown applications maliciously got inside your EC2 instances due to publicly open port and triggered some unknown/malicious traffic, then in that case also AWS can block/shutdown those ports.