0
votes

Tried connecting an Amazon RDS database to an EC2 instasnce. Both are in new VPC getting this error:

 Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I have 1 public subnet for EC2 and 2 private subnets for database, created subnet group and security groups.

RDS security group tried with below inbound rules:

option: 1
PostgreSQL  TCP 5432    0.0.0.0/0                               Traffic from EC2
All traffic All All sg-0706b9fb2d2c2dbce / public-sc-eks-demo   Public Subnet SC

option: 2
PostgreSQL  TCP 5432    <ec2 ip address>                    Traffic from EC2
All traffic All All sg-0706b9fb2d2c2dbce / public-sc-eks-demo   Public Subnet SC

Do we need outbound rules for EC2 security group?

1
I wonder why the error message is saying Is the server running locally? How are you connecting to the database? What connection details are you using?John Rotenstein

1 Answers

0
votes

It appears that you have:

  • An Amazon EC2 instance in the same VPC as an Amazon Redshift database
  • You wish to connect to the Redshift database from the EC2 instance

From security standpoint, you should have two security groups:

  • One security group on the Amazon EC2 instance (EC2-SG) with sufficient Inbound rules for you to be able to login, and default Outbound rules that Allow All traffic, and
  • One security group on the Amazon RDS instance (DB-SG) that permits Inbound access on port 5432 from EC2-SG

That is, the DB-SG should specifically reference EC2-SG in the Inbound rules.