title: PostgreSQL password authentication failed for user "postgres", not the same user as specified in my app config
body: <p><strong>What fixed it for me:
  in config/database.yml
  I added the line, user:myapp, and took care to restart server as root user.</strong> </p>
  
  <p>Original problem:</p>
  
  <p>I am having problems with setting up PostGreSQL on my Ubuntu 12.04 VPS (hosted on DigitalOcean) with my Rails 4 App (Development Environment).</p>
  
  <pre><code>root@ip.address$ su - postgres
  postgres@ip.address $ psql
  </code></pre>
  
  <p>I have created a role 'myapp' (same name as my Rails app), with a password that I set in ~/.bashrc. Role 'myapp' </p>
  
  <pre><code>postgres# create role 'myapp' with password '12345';
  postgres# alter role 'myapp' with superuser;
  postgres# alter role 'myapp' with LOGIN;
  postgres# \q
  
  postgres@ip.address $ exit
  
  root@ip.address$ cd myapp/
  
  root@ip.address$ rake db:setup
  
  ...created my tables, etc...no trouble there
  </code></pre>
  
  <p>myapp/config/database.yml</p>
  
  <pre><code>default: &amp;default
    adapter: postgresql
    encoding: unicode
    # For details on connection pooling, see rails configuration guide
    # http://guides.rubyonrails.org/configuring.html#database-pooling
    pool: 5
    user: myapp
    password: &lt;%= ENV['MYAPP_DATABASE_PASSWORD'] %&gt;
  
  development:
    &lt;&lt;: *default
    database: myapp_development
  </code></pre>
  
  <p>...</p>
  
  <p>pg_hba.conf:</p>
  
  <pre><code>local   all             postgres                                trust #md5 I already tried
  
  # TYPE  DATABASE        USER            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            md5
  # IPv6 local connections:
  host    all             all             ::1/128                 md5
  </code></pre>
  
  <p>I restarted postgresql
      root@ip.address$ service postgresql restart
  It seems to restart fine...</p>
  
  <p>But when I visit my site at the ip.address, </p>
  
  <pre><code>PG::ConnectionBad
  fe_sendauth: no password supplied 
  </code></pre>
  
  <p>I check my logs
  var/log/postgresql/postgresql.main...</p>
  
  <pre><code>2014-11-21 17:24:40 UTC LOG:  database system was shut down at 2014-11-21 17:24:39 UTC
  2014-11-21 17:24:40 UTC LOG:  database system is ready to accept connections
  2014-11-21 17:24:40 UTC LOG:  autovacuum launcher started
  2014-11-21 17:24:41 UTC LOG:  incomplete startup packet
  2014-11-21 17:24:46 UTC FATAL:  password authentication failed for user "postgres"
  2014-11-21 17:24:46 UTC FATAL:  password authentication failed for user "postgres"
  2014-11-21 17:24:46 UTC LOG:  incomplete startup packet
  </code></pre>
  
  <p>I don't know the password for "postgres" and I saw from other posts it should be blank.
  I've already changed the role I wanted to be named after my appname. The PostgreSQL documentation online don't address this, or I can't seem to find it. I've checked like all the Stack Overflow posts concerning postgresql and haven't found a fix. What do I do?</p>