Manoharsinh Rana
Manoharsinh Rana

Reputation: 41

Why Connection timed error in redshift connection?

I want to connect aws redshift with aws lambda. But this gives me error that connection timed out

            Class.forName("com.amazon.redshift.jdbc42.Driver");
            System.out.println("\n\nconnecting to database...\n\n");

            connStringBuilder = "jdbc:redshift:iam://%s?AccessKeyID=%s&SecretAccessKey=%s&DbUser=%s&SessionToken=%s";
            connString = String.format(connStringBuilder, redshiftClusterURL, accessKeyId, secret, dbUser, token);

            System.out.println("connString is " + connString);
            conn = DriverManager.getConnection(connString);

Upvotes: 2

Views: 4398

Answers (1)

S Manikandan
S Manikandan

Reputation: 148

Just ensure these steps and let me know if your problem exists:

  1. First Ensure that your aws lambda function is running in VPC if its running in VPC you need to configure NAT gateway to connect to the internet and open the outbound port for the database

  2. In redshift db open the inbound port for the specified IP ranges of your VPC.

If your aws lambda is not running in VPC.

  • Open the all traffic for specified db port in redshift (but it's not recommended and not safe too)

Upvotes: 1

Related Questions