13

I am trying to connect my Sinatra app to PostgreSQL database with this tutorial: http://samuelstern.wordpress.com/2012/11/28/making-a-simple-database-driven-website-with-sinatra-and-heroku/. Everything goes fine until I try to execute:

rake:db migrate

then I get this error:

rake aborted!
PG::ConnectionBad: fe_sendauth: no password supplied

It seems like I should change my permissions in pg_hba.conf file, but, opening it, I see nothing. And, if I try to write something into it, it says it's "readonly".

Am I on the right way of getting rid of the error and where to go next?

edit: actually, if I try to open it from another text editor, it says I have no permission to.

2 Answers 2

34

So pg_hba.conf was empty because I was trying to open it with SublimeText and sublime didn't tell me that I was not permitted to read it, it just showed me an empty file.
And to edit pg_hba.conf I needed to open it through terminal

/etc/postgresql/9.3/main$ sudo subl pg_hba.conf

with sudo.

3
  • 1
    My sublime2 also wasn't able to open pg_hba.conf even with sudo. Vim worked out. Commented Mar 24, 2016 at 13:27
  • 1
    Can confirm this is also an issue (and thus fix) when using vim Commented Nov 18, 2018 at 0:09
  • 1
    Thank you so much @lakesare for asking and answering this question. It was of great help.
    – Singh
    Commented Nov 29, 2021 at 19:04
1

In my case, I was not even able to edit or see the content of pg_hba.conf file.

What worked was:

/etc/postgresql/14/main$ sudo vi pg_hba.conf

Vi editor with sudo permission on Ubuntu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.