I have an instance in a private subnet in an Amazon VPC. This instance uses a NAT to access the Internet.
I use the Redshift JDBC driver to connect to a cluster hosted in the same region as my VPC (us-east-1).
The DriverManager.getConnection();
works and returns a connection. This should mean that the authentication succeeded. But when I execute the SQL Query via this code, the app hangs indefinitely without any error or success message:
Statement statement = connection.prepareStatement("SELECT * FROM users");
ResultSet result = statement.executeQuery();
Why ?
Some details:
- I have tried outside the VPC and it works.
- I changed the DNS resolution servers in the instances (NAT and private instance)
- The same code locally on my machine works fine.
- The query is visible in Redshift and is aborted after 14 minutes.
- The same query takes 9 seconds when it is executed from my machine.
- I could not find any specific error in the logs of the instances.
Best Answer
Have you tried using the postgresql client from your VPC instance? I had the same issue and it was the security group applied to my instance.