title: Homebrew postgres broken
body: <p>I installed Postgresql 9.4.0 installed on my Mac (10.10.1/Yosemite) using homebrew. It does not work.</p>
  
  <p>I have created the softlink to /usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist in ~/Library/LaunchAgents.</p>
  
  <p>If I try to manually load postgres I get the message that the "Operation is in progress"</p>
  
  <pre><code>&gt; launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  /usr/local/Cellar/postgresql/9.4.0/homebrew.mxcl.postgresql.plist: Operation already in progress
  </code></pre>
  
  <p>However postgres does not appear to be running.</p>
  
  <pre><code>&gt; ps auxw | grep post
  billmcn           670   0.0  0.0  2424272    452 s000  R+   10:12PM   0:00.01 grep post
  </code></pre>
  
  <p>and I cannot connect with the command line client.</p>
  
  <pre><code>&gt; psql
  psql: could not connect to server: No such file or directory
      Is the server running locally and accepting
      connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
  </code></pre>
  
  <p>To my knowledge I have tried all the fixes suggested on <a href="https://stackoverflow.com/questions/13410686/postgres-could-not-connect-to-server">other</a> <a href="https://stackoverflow.com/questions/12472988/postgres-could-not-connect-to-server-no-such-file-or-directory">Stackoverflow</a> threads discussing this problem. Specifically:</p>
  
  <ul>
  <li>I have uninstalled and reinstalled postgres and the accompanying Ruby gem. There is no postgres 8.0 version on my machine.</li>
  <li>I have verified that the psql client program is the 9.4.0 version installed by Homebrew and not a Mac system binary.</li>
  <li>I have verified that the /usr/local/var/postgres/postmaster.pid does not exist.</li>
  <li>I have rebooted the machine.</li>
  </ul>
  
  <p>I did have Homebrew postgres working on this machine earlier. I think what broke it is upgrading from version 8 to version 9 but I'm not sure.</p>
  
  <p>I don't have any databases I need to preserve. I'm willing to start clean with postgres; I just need to get it to work now. Any ideas?</p>
  
  <hr>
  
  <p>The issue appears to have been permissions on the /usr/local/var/postgres directory. Here is what my var directory looked like when things weren't working.</p>
  
  <pre><code>ll /usr/local/var/
  drwxr-xr-x  3 billmcn  admin  102 Dec 20 12:44 cache
  drwxr--r--  2 root     admin   68 Dec 29 21:37 postgres
  </code></pre>
  
  <p>(whoami = "billmcn")</p>
  
  <p>I deleted /usr/local/var/postgres, uninstalled and reinstalled postgres, and now it looks like this.</p>
  
  <pre><code>ll /usr/local/var/
  drwxr-xr-x   3 billmcn  admin  102 Dec 20 12:44 cache
  drwx------  23 billmcn  admin  782 Dec 30 10:51 postgres
  </code></pre>
  
  <p>Not sure how it got into this state because I don't remember futzing with the permissions on this directory, but no matter. It works now.</p>