Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8846331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:57:24+00:00 2026-06-14T11:57:24+00:00

Hello StackOverFlowers :) up until now I have been running my Django back end

  • 0

Hello StackOverFlowers 🙂 up until now I have been running my Django back end and my PostgreSQL database on the same micro EC2 instance.

I’ve set up two EC2 instances, one with my django back end and the other instance with my PostgreSQL database on which I use pgadminII to manage it. Both instances use the same security group and have all the same ports open. I’ve attached an Elastic IP to my Django instance and another Elastic IP to my Postgresql instance.

Now I know in the settings.py I need to change the ‘HOST’ to the address of the PostgreSQL instance. But I’m not quite sure what to put. Do I put the Elastic IP of the PostgreSQL instance?

I’ve done some research and many sources say I need to put in the internal server IP address of the PostgreSQL instance. If that’s the case how can I find the internal server IP address and input that into the ‘HOST’? I’ve copied and pasted the settings.py code below for clarity.

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 
'NAME': 'django_db', 
'USER': 'django_login',
'PASSWORD': 'password', 
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}

Thanks for the help, if I’m not clear enough, please comment and let me know so that I can make it clearer for you and for others 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:57:25+00:00Added an answer on June 14, 2026 at 11:57 am

    AMAZON SUPPORT

    So I ended up talking to the guys at Amazon as well after David Wolever’s reply. Just in case any of you come across this post again. Using the internal server IP alone isn’t enough, it is however a good start. If you are running Ubuntu for your Postgresql instance (preferably Natty Narwhal), make sure you edit the pg_hba.conf and postgresql.conf files.

    You can usually find those two files at: /etc/postgresql/8.4/main/(pg_hba.conf or postgresql.conf)

    Mind you, we are using Postgresql 8.4 in our stack, it proved to be the most consistent and solid version of Postgresql to run on Natty Narwhal during our tests.

    For different versions of Postgresql (9.1, 9.0 etc..) the directory to which you can find these two files aren’t the same as listed above. Make sure you know the proper directory to these files.

    STEP 1

    Go to the Amazon Management Console and make sure both instances are under the same security group. Postgresql and Django use 5432 and 8000 by default, so make sure you have those two ports open!

    STEP 2

    (Do this on the terminal on the postgresql instance)

    sudo vim postgresql.conf

    Press “i” on your keyboard to start making changes. Use the down arrow key until you come across

    LISTEN_ADDRESSES: ‘localhost’

    Get rid of the hash tag in the front, and instead of ‘localhost’, add the private IP of your postgresql instance (you can find the private ip on your EC2 management console) and you must also add 127.0.0.1.

    EXAMPLE:

    LISTEN_ADDRESSES: ‘private ip, 127.0.0.1’

    Make sure you separate the private ip and the local host address by a comma and leave it all under one quotation.

    Once you have made the changes, press ESC and press ZZ (twice in caps to save the changes)

    STEP 3

    sudo vim pg_hba.conf

    Use the down arrow key until you come across something that looks like this:

               Database administrative login by UNIX sockets
      local   all         postgres                          ident
    
      # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
    
      # "local" is for Unix domain socket connections only
      local   all         all                               md5
      # IPv4 local connections:
      host    all         all         127.0.0.1/32          trust
      # IPv6 local connections:
      host    all         all         ::1/128               md5
      local   django_db   django_login                      md5
      host    replication postgres    127.0.0.1/32          md5
      host    replication postgres    ::1/128               md5
    

    Once again, press ‘i’ on your keyboard and make the changes to it exactly the way I have it above.

    You’ll notice under IPv6, I have django_db and django_login, change it to the name of your postgresql database and your user login that you use for your postgresql database respectively.

    Once you have made the changes, press ESC and press ZZ (twice in caps to save the changes)

    STEP 4 (Almost done Hi5!)

    Restart the postgresql server using this command in the terminal:

    sudo /etc/init.d/postgresql restart

    Congrats! The server is up and running, however there is one last step.

    STEP 5

    Fire up your Django EC2 instance, go to your settings.py and look for this:

     DATABASES = {
     'default': {
     'ENGINE': 'django.db.backends.postgresql_psycopg2', 
     'NAME': 'django_db', 
     'USER': 'django_login',
     'PASSWORD': 'password', 
     'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
     'PORT': '', # Set to empty string for default. Not used with sqlite3.
     }
    

    Under ‘HOST’: ‘ ‘ , change it to ‘HOST’: ‘whatever the private IP of the Postgresql instance is’

    Save the changes. Open up a terminal and find the directory to where your manage.py file is.
    Once you are in that directory run the following command: ./manage.py syncdb

    These will create all the necessary tables for the models you created in Django. Congratulations, you have successfully created a link between your Database instance and your Django instance.

    If you have any questions, I’d be more than happy to help! Leave a comment below and I’ll get back to you ASAP! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello fellow StackOverflowers. I'm have a brain fart right now, and I cannot seem
Hello fellow StackOverflowers! I have some information in a database that I need pulled
Hello fellow StackOverflowers, I'm implementing a Binary Search Tree with pretty much the same
Hello Fellow stackoverflowers, I´m stuck writing a piece of code. I have application with
Hello we have an SQL server application running over a low bandwith connection. We
Hello Stackoverflowers! I have written a relatively simple application that consists of a login
Hello guys I am working on silverlight and I have issue regarding on database
Hello Stackoverflowers! I created a simple sqlite DB like so. //event table name private
Story so far.... Hello Stackoverflowers, me again! Right, im learning JQuery at the moment
Hello dear Stackoverflowers ! I work on a CardDAV sync source for Android 2.3.3,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.