Report this

What is the reason for this report?

Got "permission denied for public schema" error in PostgreSQL DB using App Platform

Posted on July 28, 2025

Greetings,

I’m learning how to use the DO App Platform. I saw some guides on how to deploy to the App Platform using the app.yaml file. I can attach it here without the sensitive info:

name: *************
services:
  _#_ _Backend API Service_
  - name: api
    source_dir: /
    github:
      repo: *************
      branch: main
    run_command: npm run start:prod
    build_command: npm ci && npx prisma generate && npx @nestjs/cli build
    environment_slug: node-js
    instance_count: 1
    instance_size_slug: apps-s-1vcpu-1gb
    envs:
      - key: NODE_ENV
        value: production
      - key: PORT
        value: "8080"
      - key: DATABASE_URL
        value: ${db.DATABASE_URL}
      - key: JWT_SECRET
        value: *************
    health_check:
      http_path: /health
    http_port: 8080
    routes:
      - path: /api

static_sites:
  _#_ _Frontend Angular Service_
  - name: web
    source_dir: /
    github:
      repo: *************
      branch: develop
    build_command: npm ci && npm run build
    environment_slug: node-js
    output_dir: *************
    envs:
      - key: NODE_ENV
        value: production
    index_document: index.html
    catchall_document: index.html

_#_ _Managed PostgreSQL Database_
databases:
  - name: db
    engine: PG
    version: "17"
    production: false

As I understand, setting ‘databases.production’ to ‘false’ will create a dev database which has restricted permissions. I know that the user ‘db’ which is the same username as the instance will not have permissions to create other databases or other schemas. It will only have permissions on my own dev database created here in the public schema. The thing is: The ‘db’ user doesn’t have permissions to create tables on its own ‘db’ database. I’m not sure if I’m doing something wrong but I tested login to the database using the psql and the connection string but I cannot create tables:

PostgreSQL error
PostgreSQL Permission error

Thank you in advance for your help!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey Jeoxs,

You’re right that dev databases on App Platform come with restricted permissions. You can’t create new databases or schemas, you’re expected to use the default database and the public schema that comes provisioned.

This error usually means your app might be trying to create a new schema or is connected incorrectly. Make sure it’s pointing to the default DB and schema.

There was a similar question here: https://www.digitalocean.com/community/questions/got-permission-denied-for-public-schema-error-in-database-but-can-t-get-the-connection-string-in-a-provisioned-database-inside-an-app

If you need full control over roles and schema creation, consider using a full DigitalOcean Managed Database instead of the dev one:

https://www.digitalocean.com/products/managed-databases-postgresql

Hope that helps!

- Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.