← Back to Guides
Profile image for Adam Charvat

By Adam Charvat

Published 20th January 2022

Deploying Strapi with PostgreSQL and using S3

Strapi is an open-source headless CMS solution to create and manage your own APIs. Strapi is used to manage dynamic content with multiple contributors and can power your websites, blogs and applications.

In this guide, you will learn how to set up a new Strapi v4 deployment. Configuration data will be stored in a PostgreSQL database and media uploads will use your own Amazon S3 bucket.

If you don't want to manage an S3 bucket or would like to keep everything self contained, you can set up Strapi with volumes by following this guide.

  1. Create a new bucket in your Amazon S3 and an IAM user that will be used for uploading to this bucket. The minimum required policy for your bucket is:

    "Action": [
  2. Create a new PostgreSQL database. For increased security, keep SSL enabled and External Access disabled. You can start with the smallest compute plan with 4 GB of storage and one replica.

    • Later, when you need to access the database in your local environment and run Strapi from your machine, you can use northflank forward in the Northflank CLI to forward the database for local development without enabling external access.

  3. Create a new secret group which will store the environment variables. We will manually add S3 connection details and link the database we created earlier.

    Manual Secrets

    AWS_ACCESS_KEY_IDYour AWS user’s access key
    AWS_ACCESS_SECRETYour AWS user’s access secret
    AWS_REGIONBucket region, for example us-east or eu-west-2
    AWS_BUCKETBucket name, for example strapi-media
    APP_KEYSString of two or more comma separated values
    JWT_SECRETString of 64 characters
    • Click on the key icon to use a built-in random key generator to generate long and secure strings.

    Inherited environment variables from the database

    Variable nameAlias


    • Inheriting environment variables ensures that the database connection details are automatically injected in the environment, avoiding the need to manually copy and paste them.

    • To learn more about connection details inheritance, read our changelog post.

  4. Open our template repository and click Use this template to create a new repository in your account. Our template repository has S3 upload pre-configured and you don’t have to edit any files.

  5. Create a new combined service and select your repository as the source. Select Buildpack under build options and leave default heroku/buildpacks:20. Port 8080 will be automatically detected and exposed. You can start with the smallest resource plan nf-compute-10.

Once the build succeeds and container boots up, visit the service URL to create your first administrator account.

It may take a few minutes for Strapi to set everything up, view the container logs to see progress of the startup.

Using Northflank to deploy Strapi with PostgreSQL

Northflank allows you to deploy your code and databases within minutes. Sign up for a Northflank account and create a free project to get started.

  • Multiple read and write replicas
  • Observe & monitor with real-time metrics & logs
  • Low latency and high performance
  • Backup, restore and fork databases
  • Private and optional public load balancing as well as Northflank local proxy

Share this article with your network