Can't connect to database via RDS proxy

0

Hello,

I've created an Aurora Postgres database with a default proxy connected to it. But when I try to use it, it won't connect. I tried connecting with and without the signer. Here below is the code I used:

const signer = new Signer({
        /**
         * Required. The hostname of the database to connect to.
         */
        hostname: "PROXY-ENDPOINT",
        /**
         * Required. The port number the database is listening on.
         */
        port: 5432,
        /**
         * Required. The username to login as.
         */
        username: "DATABASE-USER",
        /**
         * Optional. The AWS credentials to sign requests with. Uses the default credential provider chain in not specified.
         */
        credentials: ****** (IAM admin credentials to test with)
        /**
         * Optional. The region the database is located in. Uses the region inferred from the runtime if omitted.
         */
        region: "eu-central-1",
    });
      
    const token = await signer.getAuthToken();

    console.log(token);

    const config = {
        client: "pg",
        connection: {
            timezone: "+00:00",
            host:  "PROXY-ENDPOINT",
            port: 5432,
            user: "DATABASE-USER",
            password: token,
            database: "DATABASE-NAME",
            ssl: "Amazon RDS"
        },
        pool: {
            min: 5, 
            max: 30,
            createTimeoutMillis: 30000,
            acquireTimeoutMillis: 30000,
            idleTimeoutMillis: 30000,
            reapIntervalMillis: 1000,
            createRetryIntervalMillis: 100
        },
    };

    const database = knex(config);

I use knex as database library and I used @aws-sdk/rds-signer to get the token. I've tested the code above locally and on a EC2 instance in the same VPC. Does somebody know what I did wrong?

Thanks for the help!

~Daan

asked a year ago760 views
1 Answer
0
Accepted Answer

Hi, you may have an ip routing issue or a security group issue. That are the most 2 common root causes of such connectivity isse. I would suggest to telnet to your RDS proxy and see if you get the tcp session created.

If session is not created, it will confirm the routing or secgroup issue.

See https://netbeez.net/blog/telnet-to-test-connectivity-to-tcp/

profile pictureAWS
EXPERT
answered a year ago
profile pictureAWS
EXPERT
reviewed a year ago
  • Thanks for your response. When I try to telnet to the proxy via my EC2 instance it keeps hanging on Trying 172.31.16.26... and after a while it tries a different internal ip address. But when I do the same thing with the direct connection endpoint it connects instantly. I've looked at the VPC ids and subnets, but they are all pointing to the same. Do you know what could be miss configured?

  • Check the security group on the proxy setup

  • Thanks it worked successfully!

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