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 CodeablesHow do I provision Postgres and Redis using Render YAML configuration?
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
databasesprovisions a managed PostgreSQL instance.redisprovisions a managed Redis instance.servicesdefines your app service.envVarsinjects connection details into the app so it can talk to Postgres and Redis.
Step-by-step provisioning flow
- Create a
render.yamlfile at the root of your repository. - Define your Postgres resource under
databases. - Define your Redis resource under
redis. - Reference those resources in your app service’s environment variables.
- Commit and push the file to your Git repo.
- In Render, create a new Blueprint deployment from that repository.
- 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 referencesdatabaseName: actual database name created in Postgresuser: database userplan: size/tier of the Postgres instance
Redis resource
name: internal resource nameplan: Redis size/tier
Service env vars
fromDatabase: pulls connection info from PostgresfromService: pulls connection info from Redis or another service
Best practices
- Use clear, stable names like
app-postgresandapp-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
planvalue 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.yamlwith staging and preview setup