2

I have created django project with postgres database I have deployed my project into heroku server, and also migrate with

heroku run python manage.py migrate

I want to push my stored database to heroku database,

PGUSER=edpuser PASSWORD=1qazxsw2 heroku pg:push applications postgresql-curly-07168 --app application

but getting

> error   shiv@shiv:~/Documents/projects/django_related_project/zoedp$
> heroku pg:push applications postgresql-curly-07168 --app application
> heroku-cli: Pushing applications ---> postgresql-curly-07168  ▸   
> Remote database is not empty. Please create a new database or use
> heroku pg:reset

I also run command heroku pg:reset and again try again this time I got error

shiv@shiv:~/Documents/projects/django_related_project/zoedp$ PGUSER=edpuser PASSWORD=1qazxsw2 heroku pg:push applications postgresql-curly-07168 --app application
heroku-cli: Pushing edpapplication ---> postgresql-curly-07168
pg_dump: [archiver (db)] connection to database "application" failed: FATAL:  Peer authentication failed for user "edpuser"
pg_restore: [custom archiver] could not read from input file: end of file
 ▸    pg_dump errored with 1

here is my setting.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'applications',
        'USER': 'edpuser',
        'PASSWORD': '1qazxsw2',
        'HOST': 'localhost',
        'PORT': '5432',
        'ATOMIC_REQUESTS': True
    }
}

import dj_database_url

db_from_env = dj_database_url.config(conn_max_age=600)
DATABASES['default'].update(db_from_env)

and overwriting pg_hba.conf deny me. what should I do?

  • You probably want to use different user after resetting your database. Please confirm with heroku docs and your heroku settings what user is now being capable to write to this database. – GwynBleidD Jan 27 '20 at 09:25
  • I have the same exact error, have you found a solution? @shivshankarkeshari – Jeans K. Real Jun 11 '20 at 17:33

1 Answers1

0

I was having this issue, is more related to postgresql auth configuration rather than heroku pg:push command

I would recommend this approach:

Set a password for the postgres user: Based on this amazing answer: https://stackoverflow.com/a/26735105/3172310

At this moment: You have set a password for the postgres user and configure postgres to ask for id when using psql, which seems pg command does.

then run command as this:

PGUSER=postgres PASSWORD=pg_password heroku pg:push local_db_name DATABASE_URL --app application_name

Replacing:

  • pg_password: password for the postgres user
  • local_db_name: your local database
  • application_name: heroku app name

and should work fine!

Jeans K. Real
  • 180
  • 4
  • 13