Strapi

Deploy Strapi with Postgres and S3 uploads

Run Strapi 5 as a Node.js service with managed Postgres, its secrets fixed per environment and media uploads in an S3 bucket. This guide goes from create-strapi-app to a production Strapi on Modelence.

Last updated /Tested with Strapi 5.64.0 on Node.js 22.23

To deploy Strapi 5, build it with npm run build, which compiles the TypeScript and the admin panel, and run npm start against a PostgreSQL database, with APP_KEYS and the other secrets fixed for each environment and the Upload plugin pointed at an S3 bucket. On Modelence that takes a modelence.config.json in the project, and npx modelence@latest deploy builds Strapi on an official Node.js image and runs it as a managed container on AWS, in the region you pick out of 17, with managed MongoDB, Postgres and Redis next to it.

A new Strapi project keeps content in a SQLite file under .tmp and uploads in public/uploads. Each deploy on Modelence starts containers from a clean filesystem, so this guide puts content in Postgres and files in a bucket, and keeps content types in the repository, which is how Strapi expects to run in production anyway. We ran the build and start commands below with Strapi 5.64.0 on Node.js 22, using SQLite for the local run. If you'd rather not run Strapi at all, Strapi Cloud hosts it for you, and the comparison below covers when each fits.

Strapi on Modelence at a glance

How it runs
npm run build compiles TypeScript and the admin panel, then strapi start serves the API and /admin on the PORT Modelence sets
Database
Managed Postgres through DATABASE_CLIENT and the DATABASE_ variables that Strapi's generated config already reads
Secrets
APP_KEYS, the two token salts, both JWT secrets and ENCRYPTION_KEY are secrets set once per environment
Media
The official AWS S3 upload provider writes files to S3, Cloudflare R2 or another S3-compatible bucket
Content types
Built in development, committed under src/api, and applied to the database when Strapi starts
Health check
GET /_health answers 204 as soon as Strapi has started
Regions
17 AWS regions, with Strapi and its database in the same one

Before you start

  • Node.js 22 or newer and npm on your machine, since Strapi 5 supports Node.js 22 to 26
  • An S3 bucket and an access key that can write to it, or a bucket on an S3-compatible service such as Cloudflare R2
  • openssl or a password manager, to generate the secrets
  • A Modelence account, which you can create for free. Managed Postgres needs a paid plan, from $20 a month with that amount included as usage
  • Optionally, Claude Code, Cursor or Codex, if you'd rather have your coding agent write the files and run the deploy

Create a Strapi project

Create the project with Strapi's CLI. It offers to log you in to Strapi Cloud, which you can skip, and sets up TypeScript and SQLite by default, which is what you want on your machine. The generated config/database.ts reads DATABASE_CLIENT and picks SQLite, Postgres or MySQL from it, so the same project runs on SQLite locally and on Postgres once deployed.

Then add the two packages production needs: pg, the Postgres driver, and @strapi/provider-upload-aws-s3, the official upload provider for S3. Keep its version the same as @strapi/strapi in package.json.

bash
npx create-strapi-app@latest my-strapi
cd my-strapi
npm install pg @strapi/provider-upload-aws-s3

Build content types in development

Start Strapi in development mode and open http://localhost:1337/admin. The first visit asks you to create the admin account.

npm run develop

The Content-Type Builder saves each collection type as a schema.json file under src/api/<name>/content-types/, next to generated routes, controllers and services, and components under src/components. Commit those files: they are the schema of your production database. When Strapi starts, it compares them with the database and creates or alters tables to match, so a deploy is how a new field reaches production.

In production the builder is read-only. We tried to change a schema through the API of a production instance and Strapi answered with a 403 and Content-Type Builder modifications are disabled in production mode, which is why the schema has to come from the repository. Editors still create and publish entries in the Content Manager as usual.

Generate the secrets

Strapi reads six secrets from the environment, and the .env file the CLI generated holds values for your machine only. It's already in .gitignore, so generate a new set for each Modelence environment and keep them in your password manager:

  • APP_KEYS signs session cookies. It takes a comma-separated list, so you can rotate by putting a new key first.
  • ADMIN_JWT_SECRET signs admin panel logins, and JWT_SECRET signs the tokens the Users & Permissions plugin gives your app's users.
  • API_TOKEN_SALT and TRANSFER_TOKEN_SALT hash API tokens and transfer tokens, so changing either one invalidates every token of that kind.
  • ENCRYPTION_KEY encrypts stored API tokens so the admin panel can show them again.
bash
for name in APP_KEYS API_TOKEN_SALT ADMIN_JWT_SECRET TRANSFER_TOKEN_SALT JWT_SECRET ENCRYPTION_KEY; do
  echo "$name=$(openssl rand -base64 32)"
done

Add a database

  • MongoDBMONGODB_URI
  • PostgresDATABASE_URL
  • RedisREDIS_URL

Strapi 5 stores content, admin users, roles and media metadata in a SQL database, and PostgreSQL is the usual choice for production, as well as the database Strapi Cloud sets up by default. The config below creates a managed Postgres called strapi-db in the same region as Strapi. An empty database is enough: on its first start Strapi creates its tables and runs its internal migrations, and on later starts it applies whatever changed in your content types.

The generated config/database.ts reads the host, port, database name, user and password from separate DATABASE_* variables, so the config ties each one to the matching output of strapi-db. Connections to managed Postgres use TLS, so DATABASE_SSL is true, and DATABASE_SSL_REJECT_UNAUTHORIZED=false encrypts the connection without checking the server certificate against a CA, the same behavior as sslmode=require. To check the certificate too, put the CA certificate in DATABASE_SSL_CA and drop that line.

Data changes that a schema change can't express, such as copying a field's values before you rename it, go in migration files in database/migrations. Strapi runs each one once, at startup, before it updates the schema, and records which ones it has applied.

modelence.config.json
{
  "resources": {
    // "strapi": the service from the deploy step
    "strapi-db": { "type": "postgres", "plan": "postgres-1gb" }
  },
  "env": {
    "DATABASE_CLIENT": { "value": "postgres" },
    "DATABASE_HOST": { "type": "resource", "resource": "strapi-db", "output": "host" },
    "DATABASE_PORT": { "type": "resource", "resource": "strapi-db", "output": "port" },
    "DATABASE_NAME": { "type": "resource", "resource": "strapi-db", "output": "database" },
    "DATABASE_USERNAME": { "type": "resource", "resource": "strapi-db", "output": "user" },
    "DATABASE_PASSWORD": { "type": "resource", "resource": "strapi-db", "output": "password" },
    "DATABASE_SSL": { "value": "true" },
    "DATABASE_SSL_REJECT_UNAUTHORIZED": { "value": "false" }
  }
}

Send uploads to an S3 bucket

Strapi's default upload provider writes files to public/uploads inside the container, and a new deploy starts with that folder empty again. The AWS S3 provider writes them to a bucket instead, and Strapi saves each file's bucket URL with its metadata in Postgres. Configure it in config/plugins.ts, keeping the users-permissions and upload security settings the CLI generated:

  • CDN_URL is the public address files are served from: the bucket's own URL, such as https://my-bucket.s3.us-east-1.amazonaws.com, a CloudFront domain or an R2 public bucket URL.
  • ACL is left out when AWS_ACL isn't set, which suits new S3 buckets, where ACLs are turned off by default and public reads come from a bucket policy. Set AWS_ACL=private to keep the bucket private and have Strapi sign file URLs.
  • For Cloudflare R2 or another S3-compatible service, add S3_ENDPOINT, such as https://<account id>.r2.cloudflarestorage.com, and AWS_REGION=auto.
config/plugins.ts
import type { Core } from '@strapi/strapi';

const config = ({ env }: Core.Config.Shared.ConfigParams): Core.Config.Plugin => ({
  upload: {
    config: {
      provider: 'aws-s3',
      providerOptions: {
        baseUrl: env('CDN_URL'),
        s3Options: {
          credentials: {
            accessKeyId: env('AWS_ACCESS_KEY_ID'),
            secretAccessKey: env('AWS_ACCESS_SECRET'),
          },
          region: env('AWS_REGION'),
          endpoint: env('S3_ENDPOINT'),
          params: {
            ACL: env('AWS_ACL'),
            Bucket: env('AWS_BUCKET'),
          },
        },
      },
    },
  },
});

export default config;

Allow bucket images in the admin panel

The admin panel sends a Content Security Policy that only allows images from Strapi's own address, so thumbnails from the bucket show as broken images until its host is allowed. Replace the strapi::security entry in config/middlewares.ts with one that adds the host of CDN_URL:

import type { Core } from '@strapi/strapi';

const config = ({ env }: Core.Config.Shared.ConfigParams): Core.Config.Middlewares => {
  // The bucket's public address, such as https://my-bucket.s3.us-east-1.amazonaws.com
  const mediaHost = new URL(env('CDN_URL', 'http://localhost')).host;

  return [
    'strapi::logger',
    'strapi::errors',
    {
      name: 'strapi::security',
      config: {
        contentSecurityPolicy: {
          useDefaults: true,
          directives: {
            'connect-src': ["'self'", 'https:'],
            'img-src': ["'self'", 'data:', 'blob:', 'market-assets.strapi.io', mediaHost],
            'media-src': ["'self'", 'data:', 'blob:', 'market-assets.strapi.io', mediaHost],
            upgradeInsecureRequests: null,
          },
        },
      },
    },
    'strapi::cors',
    'strapi::poweredBy',
    'strapi::query',
    'strapi::body',
    'strapi::session',
    'strapi::favicon',
    'strapi::public',
  ];
};

export default config;

Two more changes go in config/server.ts. url gives Strapi its public address for links and the admin panel, and proxy.koa makes it trust the forwarded headers from Modelence's load balancer, which ends HTTPS and forwards plain HTTP to the container. Without it, Strapi sees every request as HTTP and from the load balancer's IP address:

import type { Core } from '@strapi/strapi';

const config = ({ env }: Core.Config.Shared.ConfigParams): Core.Config.Server => ({
  host: env('HOST', '0.0.0.0'),
  port: env.int('PORT', 1337),
  url: env('PUBLIC_URL', ''),
  proxy: { koa: env.bool('IS_PROXIED', false) },
  app: {
    keys: env.array('APP_KEYS')!,
  },
  webhooks: {
    populateRelations: env.bool('WEBHOOKS_POPULATE_RELATIONS', false),
  },
});

export default config;

Strapi listens on PORT, so on Modelence it serves on 3000, the port the platform gives a Node.js service, instead of 1337.

Describe Strapi in modelence.config.json

Add modelence.config.json at the root of the project. It builds Strapi as a Node.js service, creates the Postgres database and declares every variable Strapi reads, so the same file works for the sandbox and production environments. Commit it with the rest of the project:

modelence.config.json
{
  "$schema": "https://cloud.modelence.com/schema/modelence.config.json?version=1",
  "resources": {
    "strapi": {
      "type": "service",
      "image": "node-22-slim",
      "build": { "commands": ["npm ci", "npm run build"] },
      "start": { "commands": ["npm start"] },
      "healthCheck": { "type": "http", "path": "/_health", "gracePeriod": 120 }
    },
    "strapi-db": { "type": "postgres", "plan": "postgres-1gb" }
  },
  "env": {
    "NODE_ENV": { "value": "production" },
    "DATABASE_CLIENT": { "value": "postgres" },
    "DATABASE_HOST": { "type": "resource", "resource": "strapi-db", "output": "host" },
    "DATABASE_PORT": { "type": "resource", "resource": "strapi-db", "output": "port" },
    "DATABASE_NAME": { "type": "resource", "resource": "strapi-db", "output": "database" },
    "DATABASE_USERNAME": { "type": "resource", "resource": "strapi-db", "output": "user" },
    "DATABASE_PASSWORD": { "type": "resource", "resource": "strapi-db", "output": "password" },
    "DATABASE_SSL": { "value": "true" },
    "DATABASE_SSL_REJECT_UNAUTHORIZED": { "value": "false" },
    "APP_KEYS": { "type": "secret" },
    "API_TOKEN_SALT": { "type": "secret" },
    "ADMIN_JWT_SECRET": { "type": "secret" },
    "TRANSFER_TOKEN_SALT": { "type": "secret" },
    "JWT_SECRET": { "type": "secret" },
    "ENCRYPTION_KEY": { "type": "secret" },
    "PUBLIC_URL": {},
    "IS_PROXIED": { "value": "true" },
    "AWS_ACCESS_KEY_ID": { "type": "secret" },
    "AWS_ACCESS_SECRET": { "type": "secret" },
    "AWS_REGION": {},
    "AWS_BUCKET": {},
    "CDN_URL": {}
  }
}

Adjust the config for your project

  • npm ci installs from package-lock.json, including devDependencies such as TypeScript, which npm run build needs. That's why NODE_ENV has the default runtime scope: set for the build, it would make npm ci skip them.
  • NODE_ENV=production makes strapi start run in production mode, which turns off the Content-Type Builder's editing and auto-reload.
  • PUBLIC_URL has no value in the file, so the deploy asks for it and each environment keeps its own: https://<app>-<environment>.cloud.modelence.app or your own domain, without a trailing slash.
  • The secrets and the S3 key are declared with "type": "secret" and no value. The deploy asks for them in the browser, and you can view or change them later in the dashboard under Environment variables, where every view is logged.
  • The health check calls /_health, which Strapi answers with 204 once it has connected to Postgres and synced the schema. gracePeriod allows 120 seconds for a first start, which creates every table.
  • Strapi's engines field accepts Node.js 22 to 26. node-22-slim is the version we tested, and node-24-slim works the same way if you want a newer one.

Check the build locally

Run the same commands Modelence runs. Locally the .env file supplies the secrets and DATABASE_CLIENT falls back to SQLite, so the server starts without Postgres. Use a port other than 3000 if something already listens there. /_health should answer 204 No Content, and /admin should serve the admin panel.

bash
npm ci && npm run build && NODE_ENV=production PORT=3000 npm start
curl -i http://localhost:3000/_health

Deploy

Run the deploy command in the project directory:

npx modelence@latest deploy

It opens the browser, where you sign in and pick or create the organization, app and environment. Then it asks for the variables the environment doesn't have yet: paste the six secrets you generated and the S3 key, and enter PUBLIC_URL, AWS_REGION, AWS_BUCKET and CDN_URL. On an environment's first deploy you also pick one of the 17 AWS regions, where Strapi and strapi-db will run. After that the CLI uploads the project, builds it and follows the rollout until /_health passes.

Open /admin on the environment's URL straight away and create the first administrator, since whoever reaches that form first gets the account. To serve Strapi on your own domain, add it in the dashboard under Domains and change PUBLIC_URL to match.

Let your coding agent do it

Paste Deploy using https://modelence.com/skill.md into Claude Code, Cursor or Codex in the project. The agent reads the Modelence docs, writes modelence.config.json and the config changes, checks the build and runs the deploy, and it stops to ask you for the secrets, the bucket and anything else that needs your account.

Production readiness

Treat a schema change as a deploy

Because Strapi applies src/api to the database on every start, a deploy that removes a content type or a field also removes its table or column, and Strapi's docs say it does so without a warning or a prompt, in production too. Renaming a field in the Content-Type Builder has the same effect on the old column. Before you deploy a change like that, write a migration in database/migrations that copies the data, or export it first.

Deploy schema changes to the sandbox environment first, with a copy of production content in it, and check the Content Manager there before you deploy to production.

Move content between environments

Strapi's transfer command pushes content, media and configuration from one instance to another over HTTPS. Create a transfer token in the destination's admin panel under Settings > Transfer Tokens, then run the command from your project, here pushing from your machine to the sandbox:

npm run strapi transfer -- --to https://<app>-sandbox.cloud.modelence.app/admin

The transfer deletes the destination's existing content and files before it writes, and both sides need the same content types, so deploy the schema first. Admin users and API tokens aren't transferred. npm run strapi export writes the same data to an encrypted archive file, which works as a backup you control.

Keep backups and secrets together

Modelence backs up production Postgres at least every six hours and keeps those backups for up to 12 months, and a restore is an email to [email protected]. A restore brings back content and media metadata, while the files themselves live in the bucket, so turn on versioning on the bucket if you want to recover deleted or overwritten files too. Keep the six secrets with your recovery notes: a restored database works with new secrets, but every admin session, API token and transfer token issued before is invalidated.

Run more than one container

With content in Postgres and files in S3, Strapi keeps nothing on the container, so you can raise the container count under Configure and the load balancer spreads requests across them. Two settings are worth checking first. Each container opens up to 10 database connections by default (DATABASE_POOL_MAX), so check the total against your Postgres plan. And if you turn on Strapi's cron tasks in config/server.ts, every container runs them, so keep cron in an app with one container or make the tasks safe to run twice.

Upgrade with the Strapi upgrade tool

The generated package.json has an upgrade script that runs @strapi/upgrade, which updates every Strapi package to the same version and applies code changes between versions. Run it locally, start the project once with npm run develop to check the admin panel, then commit and deploy. Strapi runs its internal database migrations on the next start, so deploy to the sandbox first and make sure a recent production backup exists.

npm run upgrade:dry
npm run upgrade

Watch logs and memory

Strapi's request log and errors show on the environment's Logs page with no setup, one line per request with the status code and time. The dashboard shows each container's CPU and memory. In our test a production Strapi with one content type used about 270 MB of memory after start, so Small, with 0.5 vCPU and 1 GB at about $22 a month, is a reasonable first size. Building the admin panel took about 2 GB of memory on our machine, and that happens in the build, not in the running container.

Modelence vs Strapi Cloud, Railway and Render for Strapi

People who deploy Strapi usually compare Strapi Cloud, a Railway template, Render's Strapi guide and a VPS. Details below come from each provider's own pricing pages and docs, checked on November 29, 2026.

OptionHow Strapi runsContent and mediaPrice
ModelenceYour repository built on an official Node.js image, on AWS Fargate in 17 regionsManaged Postgres backed up at least every six hours; media in your S3 or R2 bucketFree plan; paid plans from $20 a month including $20 of usage, and managed databases need a paid plan
Strapi CloudHosted by Strapi from your Git repositoryA PostgreSQL database that Strapi Cloud sets upPer project, on Strapi's pricing page
RailwayA community template with PostgresA volume for local files, at $0.15 per GB a monthHobby $5 and Pro $20 a month including that much usage, then CPU and memory by use
RenderA web service from Render's Strapi guideA disk for the SQLite file and uploads, at $0.25 per GB a monthHobby $0 or Pro $25 a month per workspace, plus instances from $7 a month
VPSNode.js or Docker on a server you manage, such as Hetzner CloudThe server's disk, with backups, TLS and updates handled by youHetzner servers from €5.49 a month before VAT

Strapi Cloud fits a team that wants Strapi without touching infrastructure, and a VPS is the cheapest way to run one instance if you're comfortable patching a server and testing your own backups. Railway and Render get Strapi running from a template or guide in minutes, with files on a volume or disk, and Render's docs note that a disk keeps the service to one instance and rules out zero-downtime deploys. Modelence fits when Strapi should run on AWS next to managed MongoDB, Postgres and Redis, with backups you don't script, several containers when you need them and every setting in the repository. Railway alternatives and Railway vs Render compare those platforms more broadly, and Migrate from Railway covers moving an existing app.

Next steps

Frequently asked questions

How do I deploy Strapi?

Build it with npm run build and start it with npm start, with NODE_ENV=production, a PostgreSQL database, the six secrets from the generated .env set to new values, and the Upload plugin pointed at an S3 bucket. On Modelence that's a modelence.config.json that adds managed Postgres and declares those variables, and npx modelence@latest deploy. Content types come from the repository, so you build them locally with npm run develop and deploy them.

Why does Strapi say Content-Type Builder modifications are disabled in production?

Strapi only lets the Content-Type Builder change schemas when it runs with auto-reload, which is what npm run develop does, because each change rewrites files in src/api and restarts the server. In production mode the builder is read-only and the API answers with a 403. Make the change locally, commit the schema files and deploy, and Strapi updates the database when it starts.

Why do my Strapi uploads disappear after a redeploy?

Because the default upload provider writes files to public/uploads on the container's disk, and a new deploy starts from a fresh container. Install @strapi/provider-upload-aws-s3, configure it in config/plugins.ts with your bucket and keys, and new uploads go to S3 or another S3-compatible service. Files uploaded before the switch keep their old local URLs, so upload them again or move them to the bucket and update their URLs.

Why are images broken in the Strapi admin after switching to S3?

The admin panel's Content Security Policy only allows images from Strapi's own address by default. Configure the strapi::security middleware in config/middlewares.ts so that img-src and media-src include your bucket's host, such as my-bucket.s3.us-east-1.amazonaws.com, or your CDN domain. If uploads fail outright with AccessControlListNotSupported, the bucket has ACLs turned off and the provider is sending one, so remove ACL from params or leave AWS_ACL unset.

Which port does Strapi use in production?

Strapi listens on the PORT environment variable and falls back to 1337, as set in config/server.ts. On Modelence the platform sets PORT to 3000 for a Node.js service, and the generated config already binds to 0.0.0.0, so Strapi needs no change to receive traffic and pass the health check.

What happens if I change APP_KEYS or the JWT secrets?

Changing ADMIN_JWT_SECRET logs every admin out, changing JWT_SECRET invalidates the tokens your app's users hold, and changing API_TOKEN_SALT or TRANSFER_TOKEN_SALT makes every existing API or transfer token stop working. Content isn't affected. APP_KEYS takes a list, so you can rotate it by adding a new key in front of the old one. Keep the values stable per environment, which a secret set once in the dashboard does.

How do I move content from my local Strapi to production?

Use Strapi's transfer command: create a transfer token in the destination's admin panel, then run npm run strapi transfer -- --to with the destination's /admin URL from your project. It replaces the destination's content, media and configuration, and both sides need the same content types, so deploy the schema first. Admin users and API tokens aren't transferred.

Can I use MySQL instead of Postgres with Strapi?

Strapi 5 supports PostgreSQL, MySQL, MariaDB and SQLite, and the generated config/database.ts switches between them with DATABASE_CLIENT. Postgres is what Strapi Cloud sets up by default, and it's the managed SQL database Modelence creates from modelence.config.json. An external MySQL database works too: set DATABASE_CLIENT=mysql and declare its host, user and password as secrets.

How do I upgrade Strapi 5?

Run npm run upgrade, which uses @strapi/upgrade to move every Strapi package to the latest version and apply code changes between versions, or npm run upgrade:dry to preview them. Check the project locally, commit and deploy, and Strapi runs any internal database migrations when it starts. Deploy to the sandbox environment first and make sure a recent backup of production exists.

How much does it cost to host Strapi on Modelence?

Modelence has a free plan, but Strapi needs managed Postgres, which is on paid plans from $20 a month with $20 of usage included. That usage pays for the Strapi container, charged hourly by its size, and for Postgres. In our test Strapi used about 270 MB of memory, so Small, with 0.5 vCPU and 1 GB at about $22 a month, is a reasonable start, and the bucket is billed by your storage provider.

Deploy other stacks

Deploy your Strapi app

Start on the free plan and move up when your app needs more.

Or paste this into your coding agent