heroku pg:pull password authentication failed heroku pg:pull password authentication failed postgresql postgresql

heroku pg:pull password authentication failed


Apparently it's possible to set the environment variables PGUSER and PGPASSWORD, as described here.

However, this won't work on windows in the given syntax. To do this on windows run the following:

SET PGUSER=[pg_username]

SET PGPASSWORD=[pg_password]

after entering these two lines Postgres will log you in with the given authentication info, instead of trying to sign in with the windows username


I've run into this problem a lot when running heroku pg:pull. The issue in my case was that the pg:pull command only works if my local PostgreSQL server has a password set.

To set a password, run psql localdb and execute this SQL:

ALTER USER my_user_name with password 'my_new_password';

(You won't necessarily be required to use this password all the time. Run psql localdb and see whether you're prompted; in my case, I can still log in to psql without the password.)

Now run heroku pg:pull --app my_heroku_app POSTGRESQL_COLOR localdb, and enter your new password (twice) when prompted.


I'm using Windows 10, 64-bit, Powershell and had to use the following commands to properly set the local PostgreSQL environment variables:

C:\> $Env:PGUSER="[pg_username]"  C:\> $Env:PGPASSWORD="[pg_password]"  

To verify that these are set properly, list all local environment variables with this:

C:\> Get-ChildItem Env: 

After doing this, I was able to run heroku pg:pull without being prompted for a password.