title: OperationalError: FATAL: password authentication failed for user
body: <p>Yesterday I was attempting to setup a django website on an Ubuntu 16.04 server on Digital Ocean. I was having some problems with Potsgresql particularly when I thought I had it all installed and tried to migrate the files, eventually I found this thread and followed the chosen answer which worked perfectly for me</p>
  
  <p><a href="https://stackoverflow.com/questions/32805224/django-db-utils-operationalerror-could-not-connect-to-server-no-such-file-or-d">django.db.utils.OperationalError: could not connect to server: No such file or directory</a></p>
  
  <p>after doing that I was able to get my site running (but with no css) on my site on :8000, I called it a day at that point.</p>
  
  <p>After returning to it today about 24hrs later and trying to do </p>
  
  <pre><code>python manage.py runserver
  </code></pre>
  
  <p>so that I can finish the setup I am now getting this error</p>
  
  <pre><code>File "/home/david/.local/lib/python2.7/site-  packages/psycopg2/__init__.py", line 164, in connect
      conn = _connect(dsn, connection_factory=connection_factory,     async=async)
  django.db.utils.OperationalError: FATAL:  password authentication     failed for user "django_user"
  FATAL:  password authentication failed for user "django_user"
  </code></pre>
  
  <p>I tried recreating the steps from the other thread but that hasn't worked, Ive open the psql shell and reset the password and double checked that the password in my keys file is correct, I also checked that the user 'django_user' is still there and the correct db has the permissions etc.</p>
  
  <p>This is my Django settings.py file </p>
  
  <pre><code>from .base import *
  DEBUG = False
  ADMINS = (
         ('My name', 'name@gmail.com'),
  )
  ALLOWED_HOSTS = ['domain name', 'www.domain name.co', 'ip address']
  
  with open('/etc/django_keys/postgres_key.txt') as f:
          PSQL_KEY = f.read().strip()
  
  DATABASES = {
          'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'NAME': 'django_db',
          'USER': 'django_user',
          'HOST': 'localhost',
          'PORT': '5432',
          'PASSWORD': PSQL_KEY,
          }
  }
  </code></pre>
  
  <p>Im pretty confused by all this, it was fine 24hrs ago, what has changed?</p>
  
  <p>thanks</p>
  
  <p>EDIT: I should add that I have read the other similar questions here where people suggest solutions about editing the pg_hba.conf file, this is something I have never done before though and Im very knew to psql and also I would like to know why this worked fine yesterday before I look at making other changes.</p>
  
  <p>This is what I see when I login to psql as the postgres user and then lookup all users and databases, should it look like this?</p>
  
  <p><a href="https://i.stack.imgur.com/JI3Jb.png" rel="nofollow noreferrer">psql screengrab</a></p>