fe_sendauth: no password supplied error after setting up PostgrsQL on Rails


So I’ve set up a PostgreSQL database on my cloud9 IDE account according to this: https://github.com/Aerogami/guides/wiki/Cloud9-workspace-setup-with-Rails-and-Postgresql

This is what my database.yml file looks like:

default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: <%= ENV[‘USERNAME’] %>
password: <%= ENV[‘PASSWORD’] %>
host: <%= ENV[‘IP’] %>

<<: *default
database: sample_app_development

<<: *default
database: sample_app_test

<<: *default
database: sample_app_production

I then created a user model, migrated it, and reloaded my app. However when I loaded the app on the local server using this command: rails server -b $IP -p $PORT on the cloud9 command line, I get the following error message: fe_sendauth: no password supplied error. I do not understand what is going wrong since I have created a superuser with a password and have included those in my database.yml file. The only thing I found was that this error can be fixed by changing the pg_hba.conf file to trust the local server. However I thought the whole point of creating a superuser and password in the Cloud9 IDE was so that you don’t have to do this. Also Cloud9 doesn’t give you access to the pg_hba.conf file.

Postgresql: What is the original settings in pg_hba.conf?

You don’t need to change the pg_hba.conf file.
Just type in these commands in the terminal:

source ~/.profile rake db:create
$ rake db:migrate

Then restart the server normally.
I know you already added ‘source ~/.profile’ to your .bash_profile file (I have used the same Github Aerogami instructions and struggled with the same issue) but for some mysterious reason Cloud9 environment (I never had to to do any of this on my Mac) requires to manually source the ‘.profile’ file after doing the setup specified in those instructions. The second command creates the new pg database in your development environment with all the configuration from your pg gem and your database.yml file.

The final ‘migrate’ command might not be necessary but again for mysterious reasons I have also had database issues fixed after just running a ‘rake db:migrate’ (If I am correct it just updates your database to be able to use your Models or any new dummy data you might have added to your development environment).

Hope this helps.