You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.7 KiB

10 years ago
---
layout: post
status: publish
published: true
title: psql could not connect to server
author:
display_name: sipp11
login: sipp11
email: sipp11@gmail.com
url: ''
author_login: sipp11
author_email: sipp11@gmail.com
wordpress_id: 978
wordpress_url: http://blog.10ninox.com/?p=978
date: '2014-04-13 02:54:27 +0700'
date_gmt: '2014-04-12 19:54:27 +0700'
categories:
- osx
tags:
- error
---
<p>There are a few problems when you think of Homebrew on OSX. This is a problem that has nothing to do with Brew at all.</p>
<p><code><br />
psql: could not connect to server: No such file or directory<br />
Is the server running locally and accepting<br />
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?<br />
</code></p>
<p>When you find this error message while getting back from system crash, freeze, or any unexpected shutdown, it only means that there is a dirty PID file pointing out the somewhere empty. Basically every daemons will create .pid to store process number, socket and such, so when need, it will be able to do it right and delete right after shutting down the daemons. However, when unexpected shutdown occurs, no time for cleaning up .pid file, that's where problems start. Everyone will think that the daemon is running (its .pid file exists) and asking for something, surely that .pid file can only lead to false route.</p>
<p><strong>Solution</strong>: you do clean up for system. In this case, Brew's PostgreSQL .pid file is at <code>/usr/local/var/postgres/postmaster.pid</code><br />
<code><br />
$ sudo /usr/local/var/postgres/postmaster.pid<br />
</code><br />
Then you can start your postgres again. It's the same with every other daemons; you just need to find its PID file.</p>