- Newest
- Most votes
- Most comments
Hello.
If you install the psql command on the EC2 instance and try to connect with the following command, will you get an error?
psql -h <Redshift Serverless endpoint> -U <Admin User> -d dev -p 5439
It sounds like you're experiencing connectivity issues between your EC2 instance and your Amazon Redshift Serverless endpoint. Here are some steps you can take to troubleshoot and potentially resolve the issue:
-
Verify the connection string: Ensure you're using the correct endpoint for your Redshift Serverless workgroup. The format should be:
workgroup-name.account-number.aws-region.redshift-serverless.amazonaws.com
-
Check security group configuration: Although you mentioned that all traffic is allowed on all ports, double-check that the security group associated with both your EC2 instance and Redshift Serverless workgroup explicitly allows inbound traffic on port 5439 (the default Redshift port).
-
Verify VPC configuration: Confirm that your VPC has an internet gateway configured in its route table. Even though both EC2 and Redshift are in the same VPC, proper routing is still necessary.
-
Test connectivity: Try connecting to your Redshift Serverless using a database client like psql or a GUI tool from your EC2 instance. This can help isolate whether the issue is specific to your database creation script or a general connectivity problem.
-
Check network ACLs: If you're using network ACLs, ensure they're not blocking the necessary traffic between your EC2 instance and Redshift Serverless.
-
Verify DNS resolution: Although you mentioned DNS and hostname resolution are enabled, double-check that your EC2 instance can resolve the Redshift Serverless endpoint hostname.
-
Consider using the Redshift Query Editor V2: As a troubleshooting step, try connecting to your Redshift Serverless from the AWS Console using Query Editor V2. If this works, it confirms that Redshift Serverless is accepting connections and narrows the issue to your EC2 instance's network configuration.
-
Review IAM roles and permissions: Ensure that the IAM role associated with your EC2 instance has the necessary permissions to interact with Redshift Serverless.
If you've verified all these points and are still unable to connect, you may need to open a support case with AWS for further assistance. They can provide more detailed troubleshooting based on your specific account and resource configurations.
Remember, you cannot ping a Redshift Serverless endpoint as it doesn't respond to ICMP packets. Use database connection tools or telnet to test connectivity on the specific port instead.
Sources
Redshift: Failed to connect | AWS re:Post
Redshift connection fails | AWS re:Post
Troubleshooting connection issues in Amazon Redshift - Amazon Redshift
Redshift Serverless stopped allowing connections | AWS re:Post
Same issue. It first takes a lot of time to respond, then it responds with this when I ran the command u sent: psql: error: connection to server at "my end point" (172.31.30.30), port 5439 failed: Connection timed out Is the server running on that host and accepting TCP/IP connections?
answered a year ago

Judging from the error message, name resolution is possible, so I don't think there is a problem with DNS. If you are getting a timeout error, there may be a problem with your security group or network ACL. Please double check that the security group you have set for Redshift Serverless is indeed set correctly. Also, please check that you have not launched it in the wrong VPC or subnet.