1
votes

I'm newbie to AWS Redshift & I'm not able to fetch data from schema from Redshift cluster. Cluster is inside VPC and having no publicly access. I configured security group and configured inbound with:

1) Type : Redshift, Protocol : TCP, Port Range: 5439, Source: 0.0.0.0/0

2) Type : Redshift, Protocol : TCP, Port Range: 5439, Source: 'Security group name'

I've followed some of the docs, blogs & various libraries like redshift_tool with pandas, SQLAlchemy, pyodbc to configure clusters for python & came up with one library to use psycopg2

conn = psycopg2.connect(
            host=HOST,
            port=RS_PORT,
            user=RS_USER,
            password=PWD)

But I'm facing following error for all the libraries including psycopg2

psycopg2.OperationalError: could not connect to server: Connection timed out Is the server running on host and accepting TCP/IP connections on port 5439?

Q1) Am I missing some steps to configure? Please do suggest if any other way is available to connect cluster with python/drivers

Q2) How to connect clusters via SSH tunnel? If this is possible way to connect then please help me with the steps.

Thanks in Advance.

1
Assuming that you are OUTSIDE the VPC, then you need to connect through ssh tunnel, this is non trivial to explain as the process depends upon a number of things, especially if it is your first time doing this. Ask a colleague who has done this already or follow some guides. You cannot connect DIRECTLY to redshift using ssh, you have to connect through another server often referred to as a "bastion". this link may help aws.amazon.com/blogs/security/…Jon Scott
From where are you trying to connect?John Rotenstein
@John Rotenstein : I'm not trying to connect cluster via SQLWorkbench or any other tools. I'm trying with psycopg2 & outside of VPC.Pujaba Zala
@PujabaZala If your VPC has no public access, how do you expect to connect to Redshift?John Rotenstein
@JohnRotenstein : Worked successfully. I forgot to connect it to VPN from my system. Thank you.Pujaba Zala

1 Answers

0
votes

Make sure you added 'VPC security groups' You can find it on 'Network and Security'.