Issue
You are seeing "PGError: ERROR: permission denied for relation" in your application logs
Resolution
The permission denied for relation
error is a general PostgreSQL error meaning that the user that's connected to the database doesn't have access to write or read a specific table.
Common causes of this error in Heroku Postgres databases are the following:
-
If you have created a new credential for your database via the Heroku CLI, you'll need to configure the appropriate permissions for this credential. The instructions to achieve this are described at Heroku PostgreSQL credentials: managing permissions.
-
Heroku Postgres Hobby/Mini/Basic tier databases have row limits enforced. When you are over your row limit and attempt to insert data you will see this error. Upgrade to a production tier database to remove this constraint or reduce the number of total rows.