Question: I get a timeout when trying to connect to my newly set up amazon redshift database.
I tried telnet:

```
telnet redshift-cluster-1.foobar.us-east-1.redshift.amazonaws.com 5439

```

With the same result.

I set the database configuration to "Publicly accessible".

Note that I am just experimenting. I have set up aws services for fun before, but don't have much knowledge of the network and security setup. So I expect it to be a simple mistake I make.

I want to keep it simple, so my goal is just to connect to the database from a local SQL client and I don't care about anything else at this stage :)

It would be great if you could give me some pointers for me to understand what the problem could be and what I should try next.

[![subnets](https://i.stack.imgur.com/mkX7d.png)](https://i.stack.imgur.com/mkX7d.png)

Answer: 
I had to add a new inbound rule to the security group and set the source to "anywhere-ipv4" or "my ip". The default inbound rule has a source with the name of the security group itself, which might mean that it is only accessible from within the VPC. At least it is not accessible from the outside.

I set the protocol to tcp and type to redshift, which seemed like the sensible choice for my use case.

See the picture for a sample configuration.

[![enter image description here](https://i.stack.imgur.com/QXRq2.png)](https://i.stack.imgur.com/QXRq2.png)
Another option you can try is to connect to it through an API. To connect to this database using a Java client, you need these values:

```
   private static final String database = "dev";
   private static final String dbUser ="awsuser";
   private static final String clusterId = "redshift-cluster-1";

```

I have never experienced an issue when using the [RedshiftDataClient](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/redshiftdata/RedshiftDataClient.html).