16

This is how my database.yml file looks (obviously there are relevant entries for testing and production as well)

development: adapter: postgresql encoding: unicode database: dbname_dev pool: 5 username: username password: tehpass 

In terminal I can successfully run the following and log in to the database:

psql -U username dbname_dev 

However after creating this new rails project and running

rails g controller ComingSoon index 

I get the following message when I go to localhost:3000/coming_soon (despite double and triple checking the login credentials)

fe_sendauth: no password supplied 

Any ideas why I can log in to these databases via "psql" but Rails cannot?

1 Answer 1

28

Database.yml:

connection: &connection adapter: postgresql encoding: unicode pool: 5 username: username password: tehpass development: <<: *connection database: dbname_development test: <<: *connection database: dbname_test production: <<: *connection database: dbname_production 

If this is not working for you then, there might be something wrong during installation.

Visit this blog, hope this might help you out.


EDIT


ERROR CASE:

e_sendauth: no password supplied fe_sendauth: no password supplied 

This happens under a stock Ubuntu install, and is due to the permissions in pg_hba.conf being too restrictive by default. To allow rails to connect, simply change the bottom of pg_hba.conf to look like this.

# TYPE DATABASE USER CIDR-ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: host all all ::1/128 trust 

Let me know if this helps or not?

Sign up to request clarification or add additional context in comments.

8 Comments

Yeah I switched to your more DRY method just because. I looked through the blog post and your most recent answer. Concerning the recent answer I'm not sure A) where that file resides and B) if it's even an issue because I'm using Lion
I guess it must be stored in /usr/local/var/postgres/
is putting your username and password in plain text really a good idea?
In ubuntu 13/10, the file pg_hba is in /etc/postgresql/9.1/main/pg_hba.conf
Make sure you restart postgresql via sudo service postgresql restart after changing pg_hba.conf. @jdscosta91 I believe the consequences are that anybody that can connect to localhost will have unrestricted access to the database so you should only really be doing this in development.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.