Data is lost after redeploy

Hi, would be grateful for help!

All my data is lost after redeploy, I guess smth is wrong with Postgres setup.

Here are the config files:


module.exports = ({ env }) => ({
  connection: {
    client: 'postgres',
    connection: {
      host: env('PGHOST'),
      database: env('PGDATABASE'),
      user: env('PGUSER'),
      password: env('PGPASSWORD'),
      ssl: env.bool(false),



Hello question does strapi say when you start it up under project information database | postgres?

You’re most likely using sqlite in production rather than postgres (very common mistake). In my observation of the forum, this issue nearly comes up every 3 to 5 days.

Common mistakes:

  • Not injecting the environment variable properly and production runs in development mode (Strapi looks at the development environment variables)
  • Multiple environment files and misunderstanding when to use each file
  • If Docker, not building the docker image with the right environment variables

Environment │ production
Database │ sqlite

Looks like I am using sqlite… How can I switch to postgres?
I’ve created config/env/production/database.js and .env.production. What else should I do?

We need more information to help answer your question.

How do you deploy your code? Is it a Docker image or a file transfer? Has the server restarted?

HI, why using sqlite in production can cause data lost, It is the sqlite problem? OR just strapi’s function as design.

Depends how you deploy and update your server. If you build a solution that creates a new server with SQLite in the file system, the SQLite database you have in your codebase will be deployed - not the current one that is in production in the existing instance.

There are, of course, ways to get around this.