title: PG:ConnectBad Rails 4 Postgresql
body: <p>I know it seems like this question has been asked a hundred times but this time I think it is different.</p>
  
  <p>When I restart my mac and run rails s, the site works fine.</p>
  
  <pre><code>➜  BankingApp git:(master) ✗ which psql
  /Applications/Postgres.app/Contents/MacOS/bin/psql
  ➜  BankingApp git:(master) ✗ which postgres
  /Applications/Postgres.app/Contents/MacOS/bin/postgres
  </code></pre>
  
  <p>But when I restart the server, it gives this error every time.</p>
  
  <p>I am using osx mountain lion and Postgres.app. I am also using omyzsh which uses .zshrc. In that file I have:</p>
  
  <pre><code>PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
  export PGHOST=localhost
  </code></pre>
  
  <p>I also have Postgres.app running. </p>
  
  <p>Database.yml</p>
  
  <pre><code>development:
    adapter: postgresql
    database: BankingApp
    pool: 5
    timeout: 5000
  </code></pre>
  
  <p>If I open the database with PGAdmin 3, I can select from tables etc. It seems to be working. I think there must be a rogue process that is giving this error.</p>
  
  <pre><code>could not connect to server: No such file or directory Is the server running locally and                 accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
  
  Rails.root: /Users/jod/BankingApp
  </code></pre>
  
  <p>Trace:  </p>
  
  <pre><code>activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:796:in `initialize'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:796:in `new'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:796:in `connect'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:513:in `initialize'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
  /Users/jod/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
  activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
  </code></pre>