I just recently switched from my Homebrew installation (which was a bit of a pain to manage) to PostgresApp. For some reason, it seems to be trying to connect to homebrew's binary.
$ 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"?
and if I try and specify the host:
$ psql -h localhost
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5432?
And yes, it is attempting to use the right binary.
$ which psql
/Applications/Postgres.app/Contents/MacOS/bin/psql
I really need this to work, so any help would be greatly appreciated!
This is really a big issue because I cannot do any work at work and any help would be appreciated! Please!
Ok. Issue resolved. It was a memory allocation issue (remnant of homebrew installation). All I did was run
sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216
and it worked like a charm.
Hmm I am getting the same issue, PATH is setup correctly but which shows /usr/bin/psql still and not the postgressapp path.
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"?
No idea whats going on. Not using homebrew either, this is a fresh install of OS X 10.8
This occurred to me immediately after upgrading to OS X 10.8.2. Postgres.app reports it's running on 5432, lsof and netcat show it's not, but the process is running. Matt's shared memory tweaks and a relaunch brought it right up.
Postgres.app is the first and only PostgreSQL install on this machine, so this is unrelated to homebrew remnants.
@mattdbridges I've had the same issue as you, moving from Homebrew to Postgres.app. (OSX 10.8.2)
Your memory tweak worked for me as well.
The only issue is, I now have to repeat it every time I want to connect to Postgres on port 5432.
(eg. starting my Rails app).
Have you had this issue as well? Any pointers would be greatly appreciated, thanks in advance!
@cabgfx I'm glad the fix worked. However, I don't remember what fixed the issue. I think I just did a bunch of digging around on Google about completely removing Postgres in a Homebrew install. I don't remember it working right away, but somewhere along the line, it just works...
I know. Not very helpful. I didn't have a clue what I was doing when doing my searching around and still don't. Wish you the best!
@mattdbridges Thanks anyway!
@mattdbridges FWIW, I actually ended my woes re: that memory tweak, by completely uninstalling Postgres.app (incl. plist's and related cruft) and _re-installing_ PG (9.2.1). w/ Homebrew.
Don't know if it's helpful, but hey…
@cabgfx Glad you were finally able to get that fixed!
If anyone is having this problem, this is what worked for me: http://stackoverflow.com/questions/12028037/postgres-app-could-not-start-on-port-5432/13847738#13847738
@eezis Thanks! I will definitely give this a try next chance I have. I did run into this issue again not too long ago and didn't have time to research solutions. I will post my result here.
I've been successfully using the postgress.app that Postgres provides on OSX 10.7.5. After a reboot, and more importantly, not ever having use homebrew's postgres, I got this error. Matt's memory fix did the trick, this was weird and completely unexpected. Will report back if problem persists.
I was in a similar situation to @bryanchriswhite. I have never installed or used homebrew. When I installed postgres and postgres.app and tried to run postgres.app the little elephant was saying that it could not connect on port 5432. I found the solution that @eezis mentioned from stackoverflow first but this did not work for me. I then tried Matt's memory fix and it seems to be running well. Thanks for the help everybody.
@mattdbridges' solution solved my problem but only temporarily; some hours later the problem was happening again. I read the SO question posted by @eezis and found out that one user had the same problem when running XQuartz/X11. At the time I had the problem I was running Inkscape which requires XQuartz and when I closed it and restarted Postgres.app psql worked again. Weird, eh?
@leods92 That is very interesting. In fact, I am running X11 on my machine. I wonder if that is actually a part of the actual issue. I will try to remove X11 on my machine (I'm not using it anymore) and see if it makes any difference and report back.
thats is indeed interesting, I believe I too was running X11 for GIMP...
I was running X11 for Inkscape. I removed inkscape, logged out, and re-logged in. I opened a terminal and ran this:
$ 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"?
Then I opened Postgres.app and did the same thing.
$ psql
psql (9.1.4)
Type "help" for help.
mattbridges=#
So, I don't seem to have the problem anymore, but I don't know if it was because of Inkscape or something else.
Also, I put this in my ~/.bash_profile to make it easier on myself for anyone still experiencing the problem
alias postgres_fix="sudo sysctl -w kern.sysv.shmall=65536 && sudo sysctl -w kern.sysv.shmmax=16777216"
Hope this helps!
This issue happened to me again today after restarting my mac, no X11 in sight this time :-/
Hrmm. Not sure how to help anymore. I don't have the issue and I just upgraded to the latest version of Postgres.app. I'll keep following here to see if anything develops...
_Update Postgres App's config._ You most likely have something in .bashrc which is telling psql to use sockets.
Edit ~/Library/Application\ Support/Postgres/var-9.5/postgresql.conf
or wherever you're Postgres App is getting it's configuration from, and set a valid value for
unix_socket_directories=
Then restart Postgres App..
http://iamvery.com/2013/06/17/postgresapp-with-unix-socket.html
This is what helped me (mainly with getting Ruby to connect). Put it in your .bashrc or .bash_profile.
shell
export PGHOST=localhost
Thanks @humancopy! That worked for me.
Most helpful comment
This is what helped me (mainly with getting Ruby to connect). Put it in your
.bashrcor.bash_profile.shell export PGHOST=localhost