· 8 years ago · Aug 18, 2017, 04:28 PM
1OperationalError at /admin/login/
2FATAL: password authentication failed for user "usr"
3FATAL: password authentication failed for user "usr"
4Request Method: POST
5Request URL: https://www.***.com/admin/login/?next=/admin/
6Django Version: 1.11
7Exception Type: OperationalError
8Exception Value:
9FATAL: password authentication failed for user "usr"
10FATAL: password authentication failed for user "usr"
11Exception Location: /***/lib/python3.5/site-packages/psycopg2/__init__.py in connect, line 130
12Python Executable: ***
13Python Version: 3.5.2
14
15DATABASES = {
16 'default': {
17 'ENGINE': 'django.db.backends.postgresql',
18 'NAME': 'db',
19 'USER': 'usr',
20 'PASSWORD': os.environ["DB_PASSWORD"],
21 'HOST': 'localhost',
22 }
23}
24
25export DB_PASS="*******"
26
27export SECRET_KEY="******************************"
28
29[Unit]
30Description=gunicorn daemon
31After=network.target
32
33[Service]
34User=*****
35Environment=SECRET_KEY="**********************************"
36Environment=DB_PASS="***********"
37Group=www-data
38WorkingDirectory=/home/***/vp/vp/
39ExecStart=/home/***/vp/vpenv/bin/gunicorn --workers 3 --bind unix:/home/***/v$
40
41
42[Install]
43WantedBy=multi-user.target
44
45List of databases
46 Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
47-----------+----------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------
48 postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 6992 kB | pg_default | default administrative connection database
49 template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +| 6857 kB | pg_default | unmodifiable empty database
50 | | | | | postgres=CTc/postgres | | |
51 template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +| 6857 kB | pg_default | default template for new databases
52 | | | | | postgres=CTc/postgres | | |
53 db | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres +| 7600 kB | pg_default |
54 | | | | | postgres=CTc/postgres+| | |
55 | | | | | vpusr=CTc/postgres | | |
56
57List of roles
58 Role name | Attributes | Member of
59-----------+------------------------------------------------------------+-----------
60 postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
61 vp | | {}
62 usr | | {}
63
64[Service]
65...
66EnvironmentFile=/pathto/somefilewith_secrets
67
68[Service]
69...
70Environment="DATABASE_PASSWORD=mypassword"
71
72/path-to-virtualenv/gunicorn
73 --bind unix:/path_to_myproject.sock myproject.wsgi:application
74 -e DATABASE_PASSWORD=mypassword -e my_var2=value2
75
76> DATABASES = {
77 'default': {
78 'ENGINE': 'django.db.backends.postgresql_psycopg2',
79 'NAME': 'db',
80 'USER': 'usr',
81 'PASSWORD': os.environ.get("DB_PASSWORD"),
82 'HOST': 'localhost',
83 'PORT': '',
84 }