Unable to send POST request to Express Application listening in EC2 instance


My Express application which is listening on port 4000 is not receiving any request based on what I see in the application logs. However, I can send the POST request through postman on my development machine no issue

I tried configurations such as opening up 4000 for all ip address or even all port for all ip address. I would always get the problem below

"Failed to connect to [website] port 4000: Connection refused"

I am using a form application which have limited capabilities to allow me to debug from the form side. The error message is the best I can get.

The only way I could get the POST request successfully sent is by using ngrok on EC2 itself which I know would bypass many configurations. I used the HTTP link provided by ngrok, which means SSL is not an issue I think?

Hence, I suspect the problem is on AWS side, but I am unfamiliar with AWS and is there a service I can use to identify the problem?

asked 2 years ago492 views
1 Answer

Can you tell us more about your setup? Is your EC2 instance behind an Application Load Balancer? Does your EC2 instance have a public IP address assigned? Is your EC2 instance in a public subnet? If not, do you have a NAT Gateway setup? Does your VPC have an Internet Gateway attached?

Here is a tutorial for setting up a web server on an EC2 instance. In your case, just replace the PHP setup with your Node JS setup. https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateWebServer.html

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions