title: How to resolve the error 'fe_sendauth: no password supplied' in Rails using PostgreSQL?
body: <p>I've tried to create my Rails app with postgresql database, but when I started <code>rails server</code>, I got this error: </p>
  
  <blockquote>
    <p>fe_sendauth: no password supplied</p>
  </blockquote>
  
  <p>Here're my actions step by step:</p>
  
  <pre><code>$ sudo apt-get install postgresql postgresql-contrib
  $ gem install pg
  $ rails new timetracker --database=postgresql --skip-unit-test
  </code></pre>
  
  <p>My <code>database.yml</code> file looks like this:</p>
  
  <pre><code>default: &amp;default
    adapter: postgresql
    encoding: unicode
    pool: 5
    host: localhost
    username: postgres
    password:
  
  development:
    &lt;&lt;: *default
    database: timetracker_development
  
  test:
    &lt;&lt;: *default
    database: timetracker_test
  
  production:
    &lt;&lt;: *default
    database: timetracker_production
  </code></pre>
  
  <p>And here's my <code>pg_hba.conf</code> file:</p>
  
  <pre><code># Database administrative login by Unix domain socket
  local   all             postgres                                peer
  
  # TYPE  DATABASE        USER            ADDRESS                 METHOD
  
  # "local" is for Unix domain socket connections only
  local   all             all                                     peer
  # IPv4 local connections:
  host    all             all             127.0.0.1/32            md5
  # IPv6 local connections:
  host    all             all             ::1/128                 md5
  
  # modified by me.
  host    all             all             127.0.0.1/32            trust
  
  host    all             all             127.0.0.1/32            trust
  
  host    all             all             ::1/128                 trust
  </code></pre>
  
  <p>So, when I do <code>rails server</code> I get the error and then here's what I get by doing this:</p>
  
  <pre><code>$ rails c
  $ ActiveRecord::Base.connection.instance_variable_get(:@config)
  </code></pre>
  
  <blockquote>
    <p>2.1.5 :001 > ActiveRecord::Base.connection.instance_variable_get(:@config)
    PG::ConnectionBad: fe_sendauth: no password supplied</p>
    
    <p>from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in <code>initialize'  from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in</code>new'     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in <code>connect'     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in</code>initialize'  from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in
    <code>new'     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in
    </code>postgresql_connection'   from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in
    <code>new_connection'  from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in
    </code>checkout_new_connection'     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in
    <code>acquire_connection'  from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in
    </code>block in checkout'   from
    /home/denis/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in
    <code>mon_synchronize'     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in
    </code>checkout'    from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in
    <code>block in connection'     from
    /home/denis/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in
    </code>mon_synchronize'     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in
    <code>connection'  from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in
    </code>retrieve_connection' ... 4 levels...     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/console.rb:9:in
    <code>start'   from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:68:in
    </code>console'     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in
    <code>run_command!'    from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands.rb:17:in
    </code>'    from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in <code>require'     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in</code>block in require'    from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in <code>load_dependency'     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in</code>require'     from /home/denis/WEB/Rails/timetracker/bin/rails:8:in <code>&lt;top
    (required)&gt;'  from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in</code>load'    from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in <code>block in load'   from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in</code>load_dependency'     from
    /home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in <code>load'    from
    /home/denis/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in</code>require'   from
    /home/denis/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in <code>require'   from -e:1:in</code>'2.1.5 :002 ></p>
  </blockquote>
  
  <p>I'm using postgresql for the first time and I guess I'm just doing something wrong.</p>
  
  <p>Could you please help me with that?</p>