I can't connect to my Amazon Redshift cluster
Last updated: 2020-02-11
I'm having trouble connecting to my Amazon Redshift cluster.
Short Description
To connect to your Amazon Redshift cluster, check the following:
- If your Amazon Redshift cluster is in a public subnet and you want to access it over the internet, then be sure that Publicly accessible is set to Yes.
- If your Amazon Redshift cluster is in a private subnet, then use a network address translation (NAT) gateway in the public subnet to access the internet. A cluster in a private subnet can connect to the internet using the NAT gateway, but the internet can't initiate a connection to the cluster.
- If you want your Amazon Redshift cluster to communicate with resources that are in a different virtual private cloud (VPC) account, then create a VPC peering connection.
Resolution
My cluster is in a public subnet, but I can't connect to it over the internet from my local computer.
Note: Before completing the steps below, make sure that your VPC has an internet gateway attached to it.
- Open the Amazon Redshift console.
- Choose Clusters.
- Select the cluster to which you are trying to connect.
- Choose the Actions tab and choose Change publicly accessible setting.
- For Allow instances and devices outside the VPC to connect to your database through the cluster endpoint, select Yes.
- Select your Elastic IP address.
- Choose Confirm.
My cluster is in a private subnet, and I can't connect to it from my local computer.
Your cluster must be in a public subnet for it to connect to a local machine.
To access a cluster from a local machine, perform the following steps:
- Open the Amazon Redshift console.
- Choose Clusters.
- Select the cluster to which you are trying to connect.
- Choose the Configuration tab to open the Cluster Properties page.
- Choose View VPCs to open the Amazon VPC console.
- In the navigation pane, choose Route Tables.
- Select the route table that is associated with the subnet where your cluster resides.
- Choose Edit.
- Choose Add route.
For IPv4 traffic, enter "0.0.0.0/0" in the Destination field, and then select the internet gateway ID for the Target field.
For IPv6 traffic, enter "::/0" in the Destination field, and then select the internet gateway ID for the Target field. - Choose Save.
My cluster can't be accessed by an Amazon Elastic Compute Cloud (Amazon EC2) instance that is in a different VPC.
Create a VPC peering connection between the VPCs. A VPC peering connection allows two VPCs to communicate with each other using private IP addresses.
- Follow the steps for Creating and Accepting a VPC Peering Connection.
Note: If the VPCs are in the same AWS account, make sure that the IPv4 CIDR blocks don't overlap. - Update both route tables.
- Update your security groups to reference peer VPC groups.
- On the EC2 instance, test the VPC peering connection using a networking utility (such as netcat). Example:
nc -zv <hostname> <port>
If the VPC peering connection is successful, then you see the following output:
$ nc -zv example.123456789.us-east-1.redshift.amazonaws.com 5439
found 0 associations
found 1 connections:
1: flags=82<CONNECTED,PREFERRED>
outif en0
src xx.xxx.xxx.xx port 53396
dst xx.xxx.xxx.xxx port 5439
rank info not available
TCP aux info available
Connection to example.123456789.us-east-1.redshift.amazonaws.com port 5439 [tcp/*] succeeded!
Related Information
Did this article help you?
Anything we could improve?
Need more help?