- heroku postgres db,
- installed postgres on local,
- nodejs
/db route -> Error error: password authentication failed for user "username"
HOW TO FIX:
###################################### 1) create db user ################################
- sudo -u postgres psql
- CREATE USER new_username;
- ALTER USER new_username SUPERUSER CREATEDB;
- check with \du
__________________________________________ links _____________________________________ https://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist/18708583#18708583 https://stackoverflow.com/questions/16973018/createuser-could-not-connect-to-database-postgres-fatal-role-tom-does-not-e/16974197#16974197
___________________________________ fix for peer problem if needed!!! ________________________
https://stackoverflow.com/questions/12720967/postgresql-how-to-change-postgresql-user-password https://stackoverflow.com/questions/18664074/getting-error-peer-authentication-failed-for-user-postgres-when-trying-to-ge https://askubuntu.com/questions/725985/postgres-pg-hba-conf-configuration https://gist.github.com/AtulKsol/4470d377b448e56468baef85af7fd614 peer auth fix
################################## 2) dump db from heroku ####################################
https://devcenter.heroku.com/articles/heroku-postgres-import-export
################################### 3) connect to your db for test ###############################
- psql -h localhost -d your_db -U username
- check with \d
https://stackoverflow.com/questions/12720967/postgresql-how-to-change-postgresql-user-password
############################### 4) change node.js server code ##########################
to fix the problem just replace "connectionString" with:
- postgres://user:password@localhost:5432/yourlocaldb_name" (ONLY FOR DEV)
"connectionString" SHOULD BE process.env.DATABASE_URL (FOR HEROKU ON PROD)