title: Postgres user does not connect to database. Even with environment variables set correctly
body: <p>Heyy, I have been struggling with this for a few days now. Hope you guys can help me out.</p>
  
  <p><strong>EDIT: After trying to print the password of the Postgres user that I have set in my settings and imported as an environment variable in my gunicorn.service file it doesn't return any value. Locally this does work. So there is an issue with importing the environment variable from the gunicorn.service file. How can I solve this?</strong></p>
  
  <p>I have hosted a website on Digital Ocean using ubuntu, nginx, gunicorn, virtualenv, Postgres and Django and while the site is visible and working, logging into the admin page gives me this error:</p>
  
  <pre><code>OperationalError at /admin/login/
  FATAL:  password authentication failed for user "usr"
  FATAL:  password authentication failed for user "usr"
  Request Method: POST
  Request URL:    https://www.***.com/admin/login/?next=/admin/
  Django Version: 1.11
  Exception Type: OperationalError
  Exception Value:    
  FATAL:  password authentication failed for user "usr"
  FATAL:  password authentication failed for user "usr"
  Exception Location: /***/lib/python3.5/site-packages/psycopg2/__init__.py in connect, line 130
  Python Executable:  ***
  Python Version: 3.5.2
  </code></pre>
  
  <p><strong>Note: for privacy reasons I have replaced the user for postgres with "usr" ,the websites address with "*</strong>" and the database name with "db".**</p>
  
  <p>The connection is not happening between my Postgres user and Postgres database. </p>
  
  <p>When I run:<code>sudo -u postgres psql -U usr db</code> I get the same error.</p>
  
  <hr>
  
  <p>I use environment variables for the passwords as you can see below:</p>
  
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql',
          'NAME': 'db',
          'USER': 'usr',
          'PASSWORD': os.environ["DB_PASS"],
          'HOST': 'localhost',
      }
  }
  </code></pre>
  
  <p>My environment variables are in the .bashrc file:</p>
  
  <pre><code>export DB_PASS="*******"
  
  export SECRET_KEY="******************************"
  </code></pre>
  
  <p>when I run the python shell and print the DB_PASSWORD that I import from the OS library, the password is correct.</p>
  
  <p>My gunicorn.service file:</p>
  
  <pre><code>[Unit]
  Description=gunicorn daemon
  After=network.target
  
  [Service]
  User=*****
  Environment=SECRET_KEY="**********************************"
  Environment=DB_PASS="***********"
  Group=www-data
  WorkingDirectory=/home/***/vp/vp/
  ExecStart=/home/***/vp/vpenv/bin/gunicorn --workers 3 --bind unix:/home/***/v$
  
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>When I get in psql and use <code>\l+</code> to list all databases I get the following table:</p>
  
  <pre><code>                                                             List of databases
     Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   |  Size   | Tablespace |                Description                 
  -----------+----------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------
   postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 6992 kB | pg_default | default administrative connection database
   template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 6857 kB | pg_default | unmodifiable empty database
             |          |          |             |             | postgres=CTc/postgres |         |            | 
   template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 6857 kB | pg_default | default template for new databases
             |          |          |             |             | postgres=CTc/postgres |         |            | 
   db      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres         +| 7600 kB | pg_default | 
             |          |          |             |             | postgres=CTc/postgres+|         |            | 
             |          |          |             |             | vpusr=CTc/postgres    |         |            | 
  </code></pre>
  
  <p>The list of users <code>\du</code>:</p>
  
  <pre><code>                                   List of roles
   Role name |                         Attributes                         | Member of 
  -----------+------------------------------------------------------------+-----------
   postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
   vp        |                                                            | {}
   usr     |                                                            | {}
  </code></pre>
  
  <p>Thank you in advance!</p>