This is a step-by-step guide for deploying a Strapi project on Heroku. Databases that work well with Strapi and Heroku are provided instructions on how to get started.
# Heroku Install Requirements
- You must have Git installed and set-up locally.
- You must have a free Heroku account before doing these steps.
If you already have the Heroku CLI installed locally on your computer. Skip to Login to Heroku.
# 1. Heroku CLI Installation
Download and install the
Heroku CLI for your operating system:
# 2. Login to Heroku from your CLI
Next, you need to login to Heroku from your computer.
Follow the instructions and return to your command line.
# 3. Create a new project (or use an existing one)
Create a new Strapi project (if you want to deploy an existing project go to step 4).
If you plan to use MongoDB with your project, refer to the create a Strapi project with MongoDB section of the documentation then, jump to step 4.
When you use
--quickstart to create a Strapi project locally, a SQLite database is used which is not compatible with Heroku. Therefore, another database option must be chosen.
# 4. Update
Add the following line at end of
Even if it is usually recommended to version this file, it may create issues on Heroku.
# 5. Init a Git repository and commit your project
Init the Git repository and commit your project.
cd my-project git init git add . git commit -m "Initial Commit"
# 6. Create a Heroku project
Create a new Heroku project.
You can use
heroku create custom-project-name, to have Heroku create a
custom-project-name.heroku.com URL. Otherwise, Heroku will automatically generate a random project name (and URL) for you.
If you have a Heroku project app already created. You would use the following step to initialize your local project folder:
heroku git:remote -a your-heroku-app-name
Your local development environment is now set-up and configured to work with Heroku. You have a new Strapi project and a new Heroku app ready to be configured to work with a database and with each other.
# 7. Heroku Database set-up
Below you will find database options when working with Heroku. Please choose the correct database (e.g. PostgreSQL, MongoDB, etc.) and follow those instructions.
# 8. Commit your changes
git add . git commit -m "Update database config"
# 9. Deploy
git push heroku master
The deployment may take a few minutes. At the end, logs will display the url of your project (e.g.
https://mighty-taiga-80884.herokuapp.com). You can also open your project using the command line:
If you see the Strapi Welcome page, you have correctly set-up, configured and deployed your Strapi project on Heroku. You will now need to set-up your
admin user as the production database is brand-new (and empty).
You can now continue with the Tutorial - Creating an Admin User, if you have any questions on how to proceed.
For security reasons, the Content Type Builder plugin is disabled in production. To update content structure, please make your changes locally and deploy again.
# Project updates
When Strapi is deployed to Heroku, Heroku sets the environment variable to
production mode Strapi disables the content-type builder (for security reasons). Additionally, if you wanted to change the default production mode in Heroku, it wouldn't work as the file system is temporary. Strapi writes files to the server when you update the content-types and these updates would disappear when Heroku restarts the server.
Therefore, modifications that require writing to model creation or other json files, e.g. creating or changing content-types, require that you make those changes on your dev environment and then push the changes to Heroku.
As you continue developing your application with Strapi, you may want to use version control, or you can continue to use
Git push heroku master to commit and push changes to Heroku directly.
git add . git commit -am "Changes to my-project noted" git push heroku master heroku open
# File Uploads
Like with project updates on Heroku, the file system doesn't support local uploading of files as they will be wiped when Heroku "Cycles" the dyno. This type of file system is called ephemeral, which means the file system only lasts until the dyno is restarted (with Heroku this happens any time you redeploy or during their regular restart which can happen every few hours or every day).
Due to Heroku's filesystem you will need to use an upload provider such as AWS S3, Cloudinary, or Rackspace. You can view the documentation for installing providers here and you can see a list of providers from both Strapi and the community on npmjs.com.