skip to Main Content

POSTMAN,EC2 IMAGESI’ve created a simple API in node and deployed it on an ubuntu based EC2 instance. I also installed node js on my EC2. I’ve been trying to send a POST request from POSTMAN, with a JSON file. My API will extract the required data from the received POST request and will store it on a Mongo Atlas server. I copied my private IP address of EC2 instance and used it in POSTMAN. All I could get is a ‘session timed out’ message on POSTMAN.

I just need to be able to send a POST request to my EC2 instance.

2

Answers


  1. Chosen as BEST ANSWER

    inbound-rules-picture-1Here's my server code-

    const http = require('http'); const app=require('./app.js');

    const port=process.env.PORT || 3001;

    const server=http.createServer(app);

    server.listen(port);

    inbound rules-picture-2

    inbound rules


  2. For your EC2 instance to be able to receive HTTP requests from the Internet:

    • The EC2 instance needs to be in a public subnet
    • The EC2 needs a public IP address
    • The Security Group associated with the EC2 instance should permit Inbound traffic on port 80 from a source of 0.0.0.0/0 (or, for testing purposes, just the public IP address associated with your own computer — use https://icanhazip.com/)

    If it still isn’t working, try connecting to the EC2 instance and do a curl localhost to confirm that the web server is working.

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