I encounter an issue when tying to run my Rails App using Postgres and where PSLQ could not connect to server. What I did was just few steps to fix the problem and it solved the issue running in my Rails app on PSQL Database.
> Go To Terminal and follow these few steps (Note: my PSQL latest ver is 9.3.5_1)
$ 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"?
$ brew uninstall postgresql
Uninstalling /usr/local/Cellar/postgresql/9.3.5_1...
$ brew uninstall postgresql
Error: No such keg: /usr/local/Cellar/postgresql
$ psql --version
-bash: /usr/local/bin/psql: No such file or directory
$ brew install postgresql
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/postgresql-9.3.5_1.mavericks.bottle.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/postgresql-9.3.5_1.mavericks.bottle.1.tar.gz
==> Pouring postgresql-9.3.5_1.mavericks.bottle.1.tar.gz
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/homebrew/issues/issue/2510
To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
http://www.postgresql.org/docs/9.3/static/upgrading.html
When installing the postgres gem, including ARCHFLAGS is recommended:
ARCHFLAGS="-arch x86_64" gem install pg
To install gems without sudo, see the Homebrew wiki.
To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
postgres -D /usr/local/var/postgres
==> Summary
🍺 /usr/local/Cellar/postgresql/9.3.5_1: 2927 files, 38M
$ mkdir -p ~/Library/LaunchAgents
$ cp /usr/local/Cellar/postgresql/9.3.5_1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
pg_ctl: another server might be running; trying to start server anyway
server starting
$ env ARCHFLAGS="-arch x86_64" gem install pg
Building native extensions. This could take a while...
Successfully installed pg-0.17.1
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.17.1
Done installing documentation for pg after 1 seconds
1 gem installed
$ psql --version
psql (PostgreSQL) 9.3.5
$ psql
psql: FATAL: database "tech3" does not exist
$ sudo mkdir /var/pgsql_socket/
Password:
$ sudo ln -s /private/tmp/.s.PGSQL.5432 /var/pgsql_socket/
$ rake db:create
$ rake db:migrate
$ rails server