Establish a connection between a single EC2 instance running a Node.js application and another EC2 instance acting as a PostgreSQL

Currently, I have two running EC2 instances. One is running a Postgres server and the other is hosting a NodeJS app that needs to connect to the Postgres database. However, it appears that the connection cannot be established as I am unable to ping the Postgres instance from the app instance (using the public IP of the instance as the destination). I suspect that this issue may be related to the firewall settings. How can I configure the firewall to allow access from one instance to the other?

Answer №1

The likely cause of this problem is related to the Security Group settings. To resolve it, navigate to the AWS Web Console and locate the EC2 instance running Postgres. Check the attached Security Group and ensure that inbound access is granted for port 5432.

In addition, keep in mind that ICMP requests cannot reach EC2 instances unless the corresponding port is allowed in the Security Groups.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Login should only be tried when the error code is 403

I have encountered an issue with checking if the API token is expired. The process involves making a GET call, and if a 403 error is received from the API, then re-login is required. This is what I tried: app.get = async (body) => { return new Pro ...

Error: req.body or req.params.id is not defined in the current context (PUT and PATCH requests)

I'm experiencing an issue where both req.body and req.params.id are returning undefined even though I am using express.json() before the app.patch. I have tried changing the route to /:id, but that did not resolve the problem. Interestingly, it works ...

Neglecting to send a socket signal while assigning a variable to a socket message

In my client-side script, I am using the following snippet: socket.on('bla', function(data) { if (data == ID) { console.log('I don't understand what's happening here.'); } }) socket.on(ID, function(data) { ...

What should be the output when ending the process using process.exit(1)?

I need to update my code by replacing throw new Error('Unknown command.') with a log statement and process.exit(1);. Here is the example code snippet: private getCommandByName = (name: string): ICommand => { try { // try to fetch ...

Incorrect NPM version is installed along with Node

Hello everyone, I had previously asked this question without any response. I'm reposting in hopes of finally receiving some much-needed answers. Currently, I am following a tutorial on NodeJS. The tutorial instructs me to "install this version of npm ...

What is the best method for utilizing a function within a where clause with Knex?

Essentially, I am trying to figure out how to construct this query using Knex: SELECT * FROM usr_info WHERE login = ? AND password = PASSWORD(?) For instance: knex('usr_info') .where({ 'login': login, 'password': ...

Using node.js to extract images from a PDF document

I am looking for a way to utilize PDF similar to how ZIP or RAR is used. My goal is to store numerous images (traditional Tibetan Buddhist literature), around 60000 ideally. However, dividing them into 10-100 volumes is also acceptable. Any tool can be ut ...

transferring information from Node.js/MongoDB to the front-end (invisible in the browser)

I am trying to retrieve data from a mongodb database and pass it to the front-end. The function I have written works in the console, where I can see an array containing elements. However, when I try to view it in the browser, it shows undefined. I am worki ...

New Relic identifies mysterious delays caused by MongoDB's findOne method

After setting up newrelic to pinpoint the bottlenecks in my app, I discovered a major issue that has left me stumped. The source of most delays seems to be mongoDB user.findOne, but the biggest challenge is locating where in the code this delay is occurri ...

Troubleshooting problems with deploying an Angular app on Heroku

When I attempt to deploy my Angular app on Heroku, I am running into a 'Not found' error and getting additional information in the console ("Failed to load resource: the server responded with a status of 404"). Below is the entire Heroku build l ...

Expanding WebSocket functionality on Heroku with Node.js

Imagine a scenario where I have a substantial application managing numerous websocket connections on Heroku. To handle this high demand, the number of dynos is increased to N. How does Heroku's router distribute these new incoming websockets connecti ...

Puppeteer encountered an issue: The execution context was destroyed, possibly due to a page navigation

I have a coding challenge with submitting a form that requires a selector (await page.waitForSelector("selector")) to determine if the submission was successful. The code successfully fills out all the necessary fields in the form and submits it ...

"Despite using the setHeader function in express.js to set a cookie, an empty cookie is still being

customer: <a href="http://localhost:3001/user/login">Login</a> server: const token = jwt.sign({ broadcasterId: user.twitchId }, process.env.JWT_SECRET); res.writeHead(301, { "Location": "http://localhost:3000" ...

Transferring binary fragments to Node.js for assembly into a complete file. Creating a file

Hey there, I'm in a bit of a bind. I'm trying to send file chunks using multiple XMLHttpRequest requests and then receive these parts in Node.js to reconstruct the original file from the binary data. The issue I'm facing is that the final f ...

Choosing the user object in Passport and Express: How to determine which user data will be included in the req object?

I am working on authentication using Passport Js in my Node Js / Express app. The issue arises when dealing with large user objects that are always included in the request object, resulting in a decrease in performance for these users due to the data sche ...

Tips for identifying the version of a package that is installed using a package-lock.json file containing lockfileVersion = 3

After upgrading from Node 16 (npm 8) to Node 18 (npm 9), I noticed a difference in the structure of the package-lock.json files. Files generated with npm 8 have a lockfileVersion: 2, while those generated with npm 9 have a lockfileVersion: 3. The changes a ...

What is the best way to mimic an error when using fs.readFile for testing?

As someone new to test-driven development, I am currently working on creating an automated testing suite for my application. While I have managed to write tests that confirm the data retrieved from a successful call to Node's fs.readFile method, my c ...

"Optimize Your Data with PrimeNG's Table Filtering Feature

I'm currently working on implementing a filter table using PrimeNG, but I'm facing an issue with the JSON structure I receive, which has multiple nested levels. Here's an example: { "id": "123", "category": "nice", "place": { "ran ...

Exploring the functionalities of the read and write stream in csv-parse

Hey everyone, I'm new here and feeling a bit confused about how to properly use readstream and writestream. Currently, I'm attempting this (using the library https://www.npmjs.com/package/csv-parse) fs.createReadStream(path.join(__dirname," ...

Retrieve a formatted Word document from a C# endpoint to a Node.js server

I am currently facing an issue with my Node.js server that sends a GET request using axios to a C# endpoint with JSON as a parameter. The C# API then uses Newtonsoft.Json to deserialize the JSON, reads a Word file into memory, and inserts data. The final s ...