0

Ok, so I have Postgres.app on my mac.

It's running locally insofar as I know. (the little elephant icon in top bar)

Created a very basic rails application, and it worked fine, ie, it showed up in browser.

Trying to connect it to Navicat Lite http://www.navicat.com/. It keeps coming up with this error: FATAL: role "postgres" does not exist.

Can't quite figure out how to solve this, so I happened to come across Induction http://inductionapp.com/ and tried to use it to connect to Postgres again, and this is the error it comes up with:

Connection Error
could not connect to server: Permission denied
  Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? 

Not really sure how to solve this.

Have googled around on this, and some of the fixes seemed a little complicated, and right now, don't want to do fixes that I can't quite understand nor rollback.

Halp?

EDIT (including my bash info)

export PGHOST=localhost
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
export PATH=/usr/local/bin:$PATH
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

EDIT TWO

Ok, not sure how this happened of sorts.

Was randomly running Navicat again (sort of like a mouse in a running wheel?), and changed a few of the data entered on 'Connection Properties' page, ie, username and password - set it to what my laptop's info is.

It worked.

So, yay?

But then when I tried it with Induction, got the same error as listed in this post.

So, not sure what's going on, and why simply it works for Navicat and not Induction?

EDIT THREE

Hm ... ok, just tried Induction again, and actually typed localhost this time instead of leaving it to their default of 127.0.0.0 ... and it worked!

Hm, is this good news?

Also, the results of 'which psql' is this: /usr/bin/psql which doesn't seem right to me, given what I've put in my bash profile.

Um, not trying to prolong this post, nor add questions that could be saved for another post. I guess technically since I've got both Navicat and Induction working that this post is now invalid?

Should I make my question about psql path another post?

Please let me know.

Thank you.

Have removed results of echo $PATH.

user273072545345
  • 1,536
  • 2
  • 27
  • 57
  • See [this answer](http://stackoverflow.com/a/17813013/238814) – Daniel Vérité Jan 10 '14 at 00:25
  • @DanielVérité, interesting answer. not sure how to do `/Applications/Postgres.app/Contents/MacOS/bin/createuser -s postgres`Do I just run that in terminal window? – user273072545345 Jan 10 '14 at 04:07
  • Having to use localhost is definitely an indication that the path is somehow still wrong. Can you do an `echo $PATH`? – steakchaser Jan 10 '14 at 05:13
  • @steakchaser , have posted results of echo $PATH in post at bottom. – user273072545345 Jan 10 '14 at 05:18
  • Yep..it's not in your path. How did you edit `.bashrc`? – steakchaser Jan 10 '14 at 05:30
  • @steakchaser, I just merely did `nano ~/.bashrc` that opens that editor, then i pasted in that address, and then saved it. and of course, reloaded it via source. – user273072545345 Jan 10 '14 at 05:46
  • Make sure this (check version number) is in the front of the path entry in there: `/Applications/Postgres93.app/Contents/MacOS/bin:` – steakchaser Jan 10 '14 at 05:50
  • @steakchaser, oh ... you're saying to add that number in that line in my bash profile? – user273072545345 Jan 10 '14 at 05:56
  • @steakchaser, `PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"`, ok this is in my bash profile now instead of the earlier line. otherwise, my bash profile is identical to the one posted in the post. and yes, it's been reloaded. results of echo $PATH, however are same. – user273072545345 Jan 10 '14 at 06:01

1 Answers1

1

Seems like your rails app is trying to connect to the standard postgres installation that is shipped with OSX vs. the postgresapp.

Have you followed these steps as part of the postgresapp setup (http://postgresapp.com/documentation)?

PostgreSQL ships with a constellation of useful binaries, like pg_dump or pg_restore, that you will likely want to use. Go ahead and add the /bin directory that ships with Postgres.app to your PATH (preferably in .profile, .bashrc, .zshrc, or the like to make sure this gets set for every Terminal session):

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

Once your path is correctly set up, you should be able to run psql without a host. (If not, check that the correct version is being loaded in the PATH by doing which psql)

Also, re-install your pg gem.

Community
  • 1
  • 1
steakchaser
  • 5,198
  • 1
  • 26
  • 34