Migrate from Heroku to Render
This guide will help you migrate a Heroku app, Heroku Postgres database, and Heroku Redis instance to Render. Using Render to run your web services and databases is very similar to running them on Heroku. Additionally, many users have found that Render saves them money and provides additional functionality not available from Heroku. Read more about the differences between Render and Heroku.
This guide and associated Heroku CLI plugin covers most migration use cases. It supports migrating a Heroku app and its Heroku Postgres and Heroku Redis add-ons. You may continue using other Heroku add-ons while your app is running on Render by copying over the appropriate environment variables — e.g., if you are using Heroku’s Sengrid add-on, set
SENDGRID_PASSWORD in the Render Dashboard. Please contact us at firstname.lastname@example.org if you experience any problems migrating from Heroku to Render.
- Heroku app is using one of Heroku’s official buildpacks1
- Heroku app is not using multiple buildpacks2
- Generate a
render.yamlusing Render’s Heroku CLI Plugin
- Create Resources on Render
- Configure Environment Variables
- Copy Data From PostgreSQL and Redis
- Update DNS Configuration
Render has created a plugin for the Heroku CLI to reduce some of the manual migration steps. Install the plugin with the following command.The CLI plugin will not modify your Heroku app. It only performs read operations.
heroku plugins:install @renderinc/heroku-import
The CLI plugin will read information about your app and its add-ons and create two files:
render.yaml. Here is what the process looks like. Run it from the root of the repository containing your app’s code.
heroku render:import --app salty-waters-73797 === Gathering information about Heroku app Verifying app is using a single, official Heroku buildpack... ✔️ Getting stack image... heroku-20 Getting and translating plan... Heroku Hobby $7/mo --> Render Starter $7/mo Getting instance count... 1 Getting custom domains... 1 custom domain(s) Getting environment variables... 11 environment variable(s) Getting add-ons... 3 add-on(s) ? Select addons to import. (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed) ❯◯ postgresql-infinite-25060 using hobby-dev plan ◯ redis-perpendicular-19613 using hobby-dev plan - sendgrid-round-75662 using starter plan (Cannot import)
You will then be prompted to select the Heroku Postgres and Heroku Redis add-ons you would like to migrate to Render. After making your selections, a
render.yaml will be created for you, and the following instructions will be shown.
=== Environment variables excluded from render.yaml The following environment variables were not included in the generated render.yaml file because they potentially contain secrets. You may need to manually add them to your service in the Render Dashboard. - DATABASE_URL: postgres://jfgygkqpttdlqz:email@example.com:5432/d39e0kf7r3grvv - REDIS_TLS_URL: rediss://:firstname.lastname@example.org:12490 - REDIS_URL: redis://:email@example.com:12489 - SECRET_KEY_BASE: 41af19d9626b006f815342a9e7fe7a53bd22f0870b77e286c3a78866e8d619de3ce365de5fe32d00571818f44a24cae0969aa5963b8cc15cf8c076555916fb7d - SENDGRID_PASSWORD: isomynvn7190 === Follow these steps to complete import of service(s) and database(s) to Render 1. Add, commit, and push the generated render.yaml and Dockerfile.render to GitHub or GitLab. 2. Go to https://dashboard.render.com/select-repo?type=iac 3. Search for and select this repository. 4. Verify the plan showing the resources that Render will create, and then click 'Create New Resources'. 5. After the resources are deployed, you may need to manually add the above environment variables to your Web Service in the Render Dashboard. They were not included in the generated render.yaml because they potentially contain secrets.
Notice in the output above that environment variable names containing the following are excluded from the generated
render.yaml to reduce the chance that secrets like passwords and API keys are added to source control.
The CLI plugin has now created two files:
Dockerfile.render defines how to build your app on Render using a Heroku buildpack. The
render.yaml is Render’s Infrastructure-as-Code file. It can be used to define multiple services and databases running on Render and their relationship to each other.
Now, add these two files to source control with the following commands.
git add Dockerfile.render render.yaml git commit -m 'Prepare app for deploy to Render' git push origin
Render will create a plan to build and deploy your service along with a managed Render PostgreSQL database and Redis Private Service if your Heroku app was using these and you selected them for import in the Run CLI Plugin step above.
Review the plan and click Apply, and Render will create your resources.
If all resources were created successfully, continue to the next step. If there was an error you cannot resolve, please contact us at firstname.lastname@example.org. We’re here to help!
You may need to manually create environment variables that contain secrets like passwords or API tokens using the Render Dashboard. The CLI plugin excluded environment variables with names containing values indicating they may contain secrets.
To create or update environment variables using the Render Dashboard,
- Select Dashboard on the left
- Select the service you just created from the list
- Select the Environment tab and create or update environment variables (check the CLI plugin output if you’d like to copy from your Heroku Config Vars)
If you have created a Render PostgreSQL database, you may want to copy the data from your Heroku Postgres database to Render.
Put your Heroku app into maintenance mode so that no new data is written to the database during the copy.
<HEROKU APP NAME> is the Heroku app that owns the Heroku Postgres add-on.
heroku maintenance:on --app <HEROKU APP NAME>
Create a backup of the data in you Heroku Postgres database.
heroku pg:backups:capture --app <HEROKU APP NAME>
Download the backup. This will downlaod a file named
latest.dump to your local computer.
heroku pg:backups:download --app <HEROKU APP NAME>
latest.dump into your Render PostgreSQL database. The value for
<EXTERNAL CONNECTION STRING> can be found on the Render Dashboard page for your database.
pg_restore --verbose --no-acl --no-owner -d <EXTERNAL CONNECTION STRING> latest.dump
If your database is larger than 20GB or under heavy load, use Heroku’s instructions to create a backup of your data. After that has completed, you can use the same
pg_restore command above to import the data to your Render PostgreSQL database.
If you need to copy data from Heroku Redis to a Redis running on Render, configure Redis running on Render as a replica of your Heroku Redis instance, the primary. This may be necessary if you use Redis as a task queue. If you use Redis only for caching you likely do not need to copy data over.
- From the Redis CLI, use the
REPLICAOFcommand to configure . Depending on Heroku’s Redis configuration, you may need to provide to Redis running on Render the password for the Heroku Redis instance using
config set masterauth <password>.
- Wait until all data has been copied to Redis running on Render. The
ROLEcommands may be helpful. Here is more information on using these two commands to understand the current state of replication.
- Disable replication using the
REPLICAOFcommand on your Render Redis instance.
If your Heroku app is using a custom domain, follow the instructions to update your DNS configuration to point to Render instead of Heroku. Note that some downtime may be required between when your DNS changes propogate and when Render provisions a TLS certificate for your domain.