My posts don't persist on Heroku postgres

I followed the latest documentation for Strapi v3.x ( to deploy to Heroku, added Postgres db, deployed successfully, added admin user and created some dummy blog posts using the production admin UI (from my heroku project url).

But why does the posts not persist after the dyno stops? I understand that with images I would need something like Cloudinary (and I don’t need images), but with posts too? Doesn’t the posts just save to the postgres database?

I also noticed that when I make code changes in local and push it to heroku, it resets the entire app too and all my content is lost as well. How do I prevent that from happening in the future when I have many posts?

Did I do anything wrong? What did I miss? Apologies if this sound like a noob question as I’m not that good with node. Any general pointers would be appreciated, thank you!

Here’s my public repo: GitHub - jasonleow/strapi-lifelog

“pg”: “^8.4.1”,
“pg-connection-string”: “^2.4.0”,
“slugify”: “^1.4.0”,
“sqlite3”: “^5.0.0”,
“strapi”: “3.2.1”,
“strapi-admin”: “3.2.1”,

1 Like

I believe the issue is Heroku isn’t applying the NODE_ENV variable (I just recently modified those docs and made the assumption it automatically set NODE_ENV=production can you adjust your heroku settings and set the environment variable?

If that works I’ll adjust our documentation.

Sorry am a bit of a noob, might need a little more handholding here. Which docs should I follow? Do you mean follow this youtube tutorial? Break up the DATABASE_URL and add host, port, username etc separately?

OK I researched a bit and tried this in terminal:

heroku config:set NODE_ENV=production

And then I pushed an update to heroku to reset things:

git push heroku master

And then I added a post in the admin UI. Will update again in an hour after the dyno restarts to see if the data persists.

[Update 2:]
YES!! It works! OMG after 4 days of debugging. Thanks for the help!

A bit of feedback: I read through a lot of questions in Stack Overflow having issues with Heroku deployment due to using SQlite via --quickstart. many solutions seem to revolve around not using --quickstart, going with postgres db from the start, and even not using strapi create project but use npm instead. Will be good to address these mix of solutions because it was super confusing as to what the problem was (and highlight this solution instead).

Yes thank you :slight_smile: we do probably need to clarify that in our documentation.

Side note, glad the solution worked :wink:

Hello I am having the same issue. Its imposible to solve this! can someone help me?

    "knex": "0.21.18",
    "pg": "^8.7.3",
    "pg-connection-string": "^2.5.0",
    "slugify": "^1.6.5",
    "sqlite3": "5.0.0",
    "strapi": "3.5.4",

I have all variables set but its not coneccting to the database. Where in the error???

Hello I’m havinf the same problem, can you help me to fix it?? where is the problem exactcly i am folowing all the documentations and no positive result.

    "knex": "0.21.18",
    "pg": "^8.7.3",
    "pg-connection-string": "^2.5.0",
    "slugify": "^1.6.5",
    "sqlite3": "5.0.0",
    "strapi": "3.5.4",