PostgreSQL: ERROR: permission denied for table / schema public
The role is connected but lacks privileges on that table or schema — very common after PostgreSQL 15 removed CREATE on the public schema.
Seen on:
PostgreSQL
Meaning
Connecting to a database doesn’t grant access to its objects. Tables created by one role aren’t readable by others until granted, and since PostgreSQL 15 ordinary roles can’t create tables in public by default (“permission denied for schema public”).
Common causes
- Table owned by another role; no GRANT for the app role
- PostgreSQL 15+: no CREATE privilege on schema public for migrations
- New tables created after the GRANT (privileges aren’t automatic for future tables)
- Sequence privileges missing for serial/identity inserts (
permission denied for sequence)
⚡ Quick fix
- Make the app role the owner of its database/schema, or grant privileges
- Set default privileges so future tables are covered
- Grant USAGE on sequences too
Detailed fix by platform
PostgreSQL
- Grants for an app role (run as owner/superuser):sql
ALTER DATABASE appdb OWNER TO app; -- simplest for a dedicated DB GRANT USAGE, CREATE ON SCHEMA public TO app; -- PostgreSQL 15+ GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO app; GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO app; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO app;
How to diagnose
- Object — Table, sequence or schema?
- Owner —
\dt+/\dn+— who owns it? - Grants —
\dp tableshows privileges - Version — PostgreSQL 15+ public-schema change?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026