I am trying to connect to an AWS postgresql RDS via psycopg2. When I set my inbound rules on my security group to accept all traffic via postgresql on port 5432, I am able to connect.
However, when I constrain my inbound rule for postgresql on this port to accept traffic only from my client IP, I cannot connect and it times out. I get the error:
psycopg2.OperationalError: could not connect to server: Connection timed out Is the server running on host "[hostname]" ([some IP address]) and accepting TCP/IP connections on port 5432?
Thanks for any advice. I have tried configuring the inbound rules on my security group for my RDS instance to accept my client IP, my ec2 Instance private IP, and the IP address given in the error above, but no joy. Only accepting all traffic works. Any advice on what I'm doing wrong?
Thanks!
Identify your IP from this link: https://www.whatismyip.com/. In the security groups, enable inbound rule to this IP followed by /32.
Example, if your IP from the above link comes as 192.168.0.25, then in security groups, add 192.168.0.25/32 as the source.
In my case, I found the answer was to configure an elastic IP so that it would have a constant value that could be accepted by my RDS security group. Perhaps other posters took it for granted that I had done so; I didn't know that was was part of the solution. Thanks for everyone's advice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With