title: What's with Postgres on OS X?
body: <p>My goal is to have a Postgres setup that I can use to develop my rails app and then push it to Heroku without having to change the database config file. Seems simple enough, right?</p>
  
  <p>I've seen plenty of things on the internet about PostgreSQL 9.2.x not running on OS X 10.8, and I'm still struggling to get it working with Rails. Not realizing that a version of PSQL shipped with OS X, I set out to install it. (NOTE: I'm sort of debugging in circles, so things may not have worked as I expected.)</p>
  
  <p>I've tried downloading and installing using <a href="http://www.postgresql.org/download/macosx/" rel="nofollow">the official graphical installer listed here</a>,  and I rebooted my Mac. I saw an extra user account was created, and I promptly deleted it. (I know, I know, probably what caused some heartache down the line, but it didn't seem reasonable to have an extra user account sitting around.)</p>
  
  <p>Upon running my rails app, it couldn't connect to postgres. I tried running psql from Terminal. </p>
  
  <pre><code>psql: 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"?`
  </code></pre>
  
  <p>I then proceeded to install Postgres with homebrew. I installed homebrew, then postgres. Same thing. I googled a bit and ran into a thread on the Postgres forum. What I got from it was that something changed between OS X 10.7 and 10.8, but that wasn't the cause of my problem.</p>
  
  <p>Next, I tried using <a href="http://postgresapp.com" rel="nofollow">self-contained the Postgres.app</a>. Now, I was able to create users and connect to the database. Rails was able to connect to Postgres, but complained that the database that I defined in <code>config.yaml</code> was absent. So I created it - or so I thought. </p>
  
  <p>Running <code>CREATE DATABASE my_db</code> in the "self-contained" version of PSQL didn't work - even though without the self contained app, PSQL would have that socket error. I then tried creating a new user with write access. Nope. The <code>CREATE</code> was silently failing. </p>
  
  <p>I tried adding localhost to my environment variable and it seemed to have solved the port error - but now Rails was having trouble finding Postgres again.</p>
  
  <p>I uninstalled the brew version. I removed the enterprise tools et al. Still no luck. Reboot. Still no luck. </p>
  
  <p>I just uninstalled brew and my config looks like this:</p>
  
  <pre><code>development:
    adapter: postgresql
    database: my_db
    pool: 5
    timeout: 5000
    host: localhost
    port: 5432
  </code></pre>
  
  <p>Rails says the database doesn't exist.</p>
  
  <p><strong>What do I need to do to get Postgres working with Rails 3.2.6 on Mac OS X 10.8.4 Mountain Lion?</strong></p>