Andrew
Andrew

Reputation: 4441

AWS Elastic Beanstalk hosting PostreSQL on deployed EC2 server with Django

I'm going through my first Elastic Beanstalk deployment. I have my application loading as I'd like it to. I now need to figure out how to auto deploy PostgreSQL with my deployment

I added the following to my requirements.txt psycopg2==2.5.1

It appears to have installed

$ psql --version
$ psql (PostgreSQL) 9.2.5

settings.py in Django

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'database',
    'USER': 'user',
    'PASSWORD': 'password',
    'HOST': 'localhost',
    'PORT': '5432',
}
}

These settings work perfectly before deployment, here is the error I'm getting after deployment:

could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

I don't think I have to open up firewall settings for an EC2 instance to read it's own database, do I? Also because it's Django, everything should be auto created when the application runs.

Upvotes: 3

Views: 1159

Answers (1)

Andrew
Andrew

Reputation: 4441

As mentioned above, using PostgreSQL on the EC2 server was a bad idea for dynamic data and scaling.

Used RDS for this purpose and it worked flawlessly.

Upvotes: 1

Related Questions