Permission Denied
Error message
permission denied for table
Quick summary
The database user you are connected as does not have the necessary privileges (SELECT, INSERT, UPDATE, DELETE) on the table.
Why this happens
The user has not been granted the required privilege
You are connected as a user with limited permissions
The privilege was revoked
The user has privileges on a different database or schema
Minimal example
-- User 'reader' tries to insert
INSERT INTO users (name) VALUES ('Ada');
-- → permission denied for table users-- Grant insert privilege first
GRANT INSERT ON users TO reader;
INSERT INTO users (name) VALUES ('Ada');The user lacked INSERT permission. Granting it (as a superuser) allows the insert to proceed.
How to diagnose
Check the user's privileges:
\du usernamein psql or query the information_schemaVerify you are connected as the correct user
Check if the privilege is granted on the correct table/schema/database
How to fix
Grant the required privilege:
GRANT SELECT ON table TO userConnect as a user with sufficient privileges
Grant privileges on the schema:
GRANT USAGE ON SCHEMA schema TO user
How to prevent
Set up roles with appropriate privileges and assign users to roles
Document which users need which privileges
Use least-privilege principles — grant only what is needed
Related Resources
Related Glossary
Related Lessons
- Database Security
Learn about database permissions.