1

I'm trying to connect to my AWS rds postgres database through my Google Firebase Functions backend. After some trial and error, I successfully managed to connect to it locally (ran firebase emulators:start --only functions and successfully queried the DB). However, I am running into a { Error: connect ECONNREFUSED 127.0.0.1:3306 when I deploy my function to the remote Google Firebase Functions server.

I have set my AWS RDS database to publicly accessible. I know that I need to allow inbound traffic from my Google Firebase server, but from what I managed to dig up, this shows that the Availability Zone I am using (us-central-1) has dozens of IP addresses associated with it. I gave up and allowed all incoming traffic (Yes I know that's bad but I am not in production just yet). However, I am still getting the same error!

I have also read this and this to no avail.

Any ideas on how to get this working, and how to connect it properly so I'm not allowing all incoming traffic?

Below is how I am connecting to my aws db in my firebase function. The function itself (where the code is stored) is us-central:

  const {Pool} = require('pg');

  private static readonly config = {
    user: 'xxxxxxxx',
    host: 'xxxxxxx.yyyyyyyyy.us-east-2.rds.amazonaws.com',
    database: 'postgres',
    password: 'xxxxxxxxxx',
    port: 5432
  };
  private static readonly pool = new Pool(RemoteDBHandler.config);

Edit: Looking at it now, it is odd that the connection is being attempted on localhost (127.0.0.1). I have no idea why that's happening, since I am making the connection to the aws server. Therefore, I don't think this applies to me

Random_User
  • 71
  • 1
  • 8

0 Answers0