You can now attach a VPC-isolated Postgres database to any environment on Mastra platform, letting you restrict access to same-network resources.
Typically, hosted databases are accessible from any client. Mastra platform's VPC provides an extra layer of security by preventing access from resources hosted outside the network.
In June, we launched managed databases with Turso and Neon. VPC Postgres joins the lineup for use cases where extra restrictions are required, with MongoDB and Redis coming soon.
When using a VPC-provisioned database, --region doesn't apply. The platform deploys the database to the same region as the environment to ensure it uses the same server network.
Get started
Install or upgrade the global Mastra CLI:
npm install -g mastra@latestmastra@1.32.0 or later, added in PR #25650.Attach a database to an environment:
mastra env db create production --kind postgresOr leave DATABASE_URL in .env unset and let the preflight checks run when you next deploy:
? Preflight needs DATABASE_URL for the production environment. Which managed database should be provisioned?
❯ Neon (serverless, public)
Postgres (VPC-isolated)
Skip — set it manually laterThe platform injects DATABASE_URL at deploy time, so your PostgresStore config can remain the same:
import { Mastra } from "@mastra/core/mastra";
import { PostgresStore } from "@mastra/pg";
export const mastra = new Mastra({
// ...
storage: new PostgresStore({
id: "mastra-storage",
connectionString: process.env.DATABASE_URL!
})
});Database status
You can't connect to a VPC database from outside the network. Using psql to connect will return an error:
psql: error: could not translate host name "mastra-vpc-postgres-8d60df8b14a4.railway.internal" to address: nodename nor servname provided, or not knownTo check the status of a VPC database, use mastra env db show:
mastra env db show mastra-vpc-postgres-postgresready means provisioned and attached. mastra env db list reports the same for every database in the project and shows which environment each one is attached to.
mastra-vpc-postgres-postgres (postgres)
ID: pdb_daff2f42-6974-428e-b7e5-a4261012113d
Status: ready
Scope: environment: mastra-vpc-postgres
Region: us
Created: 2026-10-01T10:20:06.581Z
Connection env vars (injected automatically at deploy time):
DATABASE_URL=******** (use --show-secrets to reveal)For more information and full configuration options, see:
