2

I am trying to connect my local django application to amazon RDS (tried with both MySQL and PostgreSQL) but I am not able to connect as it shows the following errors, Currently seeking answer for PostgreSQL.

In my Settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'database_name',
        'USERNAME': 'my_username',
        'PASSWORD': 'my_password',
        'HOST': 'database-abc.xxx.us-region-yyy.rds.amazonaws.com',
        'PORT': '5432',
    }
}

In AWS database configuration:

enter image description here

I get this error:

django.db.utils.OperationalError: could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "database-abc.xxx.us-region-yyy.rds.amazonaws.com" (69.420.00.121) and accepting TCP/IP connections on port 5432?

I referred to all the available data but still am unable to resolve this issue!

Thanks in advance!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

2

In the VPC security group go to inbound settings create a new rule with the Postgres connection type, not HTTP and make it available from every.

Note: don't forget to make accessibility to the database to be public.

inbound rule example

Mahmoud Nasser
  • 805
  • 3
  • 16