내용으로 건너뛰기

Not able to connect to RDS via code

0

Hi, I created a postgres RDS database which I configured and was able to connect via pgAdmin. However when I try to connect to the db via code, I get timeout error

For context my vpc security group rules are as follows

Security Groups

2개 답변
1

Hi,

  1. Did you check that the TCP port used by your RDS instance matches the one in your Sec Group? If not, you requests will not go through the sec group.

  2. Does your RDS instance have a public IP address to access it over the internet from a remote machine ?

Best,

Didier

전문가

답변함 2년 전

전문가

검토됨 2년 전

전문가

검토됨 2년 전

0

1.As Shown in the rds config screenshot. The port is 5432. In the security group config ss added, 5432 port is added in security groups. Also rds is publicly available RDS Config

For additional context I am sharing the code here which I use to connect to postgres db

import psycopg2

# Database connection details
db_host = 'my endpoint'
db_port = '5432'
db_name = 'sqltrainingdb'
db_user = 'postgres'
db_password = 'password'

# Establish a connection to the database
conn = psycopg2.connect(
    host=db_host,
    port=db_port,
    dbname=db_name,
    user=db_user,
    password=db_password
)

conn

And the error I get is Error

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠