title: Postgresql adapter (pg): could not connect to server
body: <p>I get this error every this I run my Rails app (It <strong>cannot connect to my local Postgresql</strong>)</p>
  
  <pre><code>/Users/leonardo/.rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.11/lib/
  active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize': 
  could not connect to server: No such file or directory (PG::Error)
     Is the server running locally and accepting
  connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
  </code></pre>
  
  <p>I'm using <a href="http://postgresapp.com/" rel="noreferrer"><strong>Postgres.app</strong></a> that it's correctly running.</p>
  
  <p>If I run</p>
  
  <pre><code>$ psql
  </code></pre>
  
  <p>I can login properly  to Postgresql console.</p>
  
  <pre><code>$ which psql
   /Applications/Postgres.app/Contents/MacOS/bin/psql
  </code></pre>
  
  <p><strong><em>Gemfile</em></strong></p>
  
  <pre><code>source 'https://rubygems.org'
  ruby "1.9.3"
  
  gem 'rails', '3.2.11'
  gem "pg"
  </code></pre>
  
  <p><strong>database.yml</strong></p>
  
  <pre><code>development:
    adapter: postgresql
    encoding: unicode
    username: leonardo
    password: 
    database: zapping
    port: 5432  
  </code></pre>
  
  <p><strong>Postgresql</strong> (Console)</p>
  
  <pre><code>$ psql
  leonardo=# \l
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/I5eC9.png" alt="enter image description here"></p>