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?
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With