title: postgres sometimes will not start after reboot
body: <p>Something weird is happening with my postgres installation after I upgraded to version 9.3.2 homebrew.</p>
  
  <p>Sometimes and not every time,  if I enter <code>psql</code> I get this error message:</p>
  
  <blockquote>
    <blockquote>
      <p>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"?</p>
    </blockquote>
  </blockquote>
  
  <p>It also appears that postgres is running because if I try and stop postgres with this command:</p>
  
  <p><code>pg_ctl -D /usr/local/var/postgres stop -s -m fast</code></p>
  
  <p>I get this response:</p>
  
  <blockquote>
    <p>pg_ctl: server does not shut down</p>
  </blockquote>
  
  <p>If I look in the <code>server.log</code> I can see the following entries:</p>
  
  <blockquote>
    <p>FATAL:  lock file "postmaster.pid" already exists HINT:  Is another
    postmaster (PID 208) running in data directory
    "/usr/local/var/postgres"?</p>
  </blockquote>
  
  <p>After some frantic googling, I am able to cure this by entering these commands:</p>
  
  <pre><code>launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  </code></pre>
  
  <p>I would like to first of all understand what is happening and second of all I would like to fix it once and for all.</p>
  
  <p>Can anyone explain what might be happening and a cure?</p>