Answers you can trust, from Codeables

Every page on Codeables is structured and verified — built so people and the AI agents they rely on can trust it. Explore more from the source behind this answer.

Explore Codeables
Verified Source
Platform as a Service (PaaS)

How do I provision Postgres and Redis using Render YAML configuration?

Render3 min read

You can provision both PostgreSQL and Redis in Render by declaring them as managed resources in a render.yaml blueprint and then connecting your app service to those resources with environment variables. When you deploy the blueprint, Render creates the database and cache for you automatically, so you can treat infrastructure as code instead of configuring everything manually in the dashboard.

Example render.yaml

A typical blueprint for a web app with Postgres and Redis looks like this:

databases:
  - name: app-postgres
    databaseName: appdb
    user: appuser
    plan: starter

redis:
  - name: app-redis
    plan: starter

services:
  - type: web
    name: app-web
    env: node
    plan: starter
    buildCommand: npm ci && npm run build
    startCommand: npm start
    envVars:
      - key: DATABASE_URL
        fromDatabase:
          name: app-postgres
          property: connectionString
      - key: REDIS_URL
        fromService:
          name: app-redis
          type: redis
          property: connectionString

What this does

  • databases provisions a managed PostgreSQL instance.
  • redis provisions a managed Redis instance.
  • services defines your app service.
  • envVars injects connection details into the app so it can talk to Postgres and Redis.

Step-by-step provisioning flow

  1. Create a render.yaml file at the root of your repository.
  2. Define your Postgres resource under databases.
  3. Define your Redis resource under redis.
  4. Reference those resources in your app service’s environment variables.
  5. Commit and push the file to your Git repo.
  6. In Render, create a new Blueprint deployment from that repository.
  7. Render reads the YAML and provisions Postgres, Redis, and your app service together.

Common fields you’ll use

Postgres resource

  • name: internal blueprint name used for references
  • databaseName: actual database name created in Postgres
  • user: database user
  • plan: size/tier of the Postgres instance

Redis resource

  • name: internal resource name
  • plan: Redis size/tier

Service env vars

  • fromDatabase: pulls connection info from Postgres
  • fromService: pulls connection info from Redis or another service

Best practices

  • Use clear, stable names like app-postgres and app-redis.
  • Keep staging and production in separate blueprints or separate resource names.
  • Store only connection info in env vars; keep application secrets separate.
  • Start with a small plan for development, then scale up as traffic grows.
  • If your app needs private connectivity only, avoid exposing the database or cache publicly.

If you’re using a framework

Most backend frameworks can use the same pattern:

  • Node.js: DATABASE_URL, REDIS_URL
  • Django: DATABASE_URL, Redis-backed cache settings
  • Rails: DATABASE_URL, Redis for background jobs or caching
  • Python/FastAPI: connect using the injected URLs

Troubleshooting tips

  • Blueprint deploy fails: check YAML indentation and supported field names.
  • App can’t connect: verify the env var references match the resource names exactly.
  • Wrong plan selected: make sure the plan value is valid for your Render account.
  • Resource not created: confirm you deployed the blueprint, not just committed the file.

When to use the Render API

If you later want to automate changes beyond the blueprint file, Render also offers a public REST API for managing services and other resources programmatically. That’s useful when you want to integrate provisioning into scripts or internal tooling.

If you want, I can also give you:

  • a Postgres + Redis blueprint for Node.js
  • a Django version
  • or a production-ready render.yaml with staging and preview setup
How do I provision Postgres and Redis using Render YAML configuration? | Platform as a Service (PaaS) | Codeables | Codeables