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
django.db.utils.OperationalError: could not connect to server: No such file or directory
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.
After returning to it today about 24hrs later and trying to do
python manage.py runserver
so that I can finish the setup I am now getting this error
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"
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.
This is my Django settings.py file
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,
}
}
Im pretty confused by all this, it was fine 24hrs ago, what has changed?
thanks
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.
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?