Thursday, June 29, 2023

How to switch hosting from Render to Heroku for your Ruby on Rails application

We were trying out the new hosting tool, Render, for, and we ended up regretting it. Even though we were paying for their starter plan, we experienced numerous disconnection issues. After spending two days dealing with these problems, I decided to switch back to Heroku for my Rails app. Let me share with you the steps I took to make the transition.


Step 1. Download your Postgres Database from Render to your local machine

The process of downloading and uploading a Postgres database is called 'pgdump' and 'pgrestore'. Since we need to migrate from Render to Heroku, the first step is to connect to Render and download the database.


A. Add your local machine's ip address on Render.

Make sure your VPN is turned off and add the correct IP address. This will enable you to connect to your database on Render from your local machine.


B. Add -Fc for correct compression format.

Run pg_dump -Fc -d postgres://{YOUR_POSTGRESS_URL} on your local machine to download the database.

-Fc is the format for Heroku. If a backup is created with the incorrect format, pg_restore will not be able to restore the dump file. You may see an error like this: pg_restore: [archiver] did not find magic string in file header.

To run pg_dump from your local machine, install 'pgdump' using homebrew. Remember the version of `pgdumphas to be the same as Render's. Otherwise you will see this errorpg_dump: error: aborting because of server version mismatch. `

Some additional details and instructions are available here.


C. Upload your database to a cloud bucket.

Heroku doesn't allow database uploads from a local machine, so you need to store the database in a publicly accessible bucket in the cloud. Both Google Cloud and AWS are suitable options. Remember to delete it after restoring the database.


Step 2. Upload your Postgre Database to Heroku from a cloud bucket.

Assuming you have already created an account on Heroku and completed all the necessary preparations to run your app, you can now proceed by running this command to restore your database.heroku pg:backups:restore '<SIGNED URL>' DATABASE_URL --app example-app


Step 3. SSL certificate

If your app is already running on Basic or Professional dynos, enable Automated Certificate Management with the following command:
heroku certs:auto:enable


Step 4. Redis


A1: If you are using heroku data for redis

It's a way easier setup. Starting plan costs $3/month.




A2: If you want to use Redis Enterprise Cloud to save $3/month:

Set the REDIS_PROVIDER env var to the name of the env var containing the Redis server URL. (Example with RedisCloud: set REDISPROVIDER=REDISCLOUDURL and Sidekiq will use the value of the REDISCLOUD_URL env var when connecting to Redis.)

Run this command: heroku config:set REDIS_PROVIDER=REDISCLOUD_URL

You may see this error if you are running Sidekiq 7+
redis-client requires Redis 6+ with HELLO command available You have to downgrade Sidekiq to 6.5.8 version for it to work.


B: Add these lines to your procfile

worker: bundle exec sidekiq -C config/sidekiq.yml
release: bin/rails db:migrate

You are almost there:

Copy all your environment variables from Render to Heroku, ensure everything is up and running, and confirm that your Sidekiq jobs are executing. Once you have verified these aspects, you can safely suspend the usage of Render. You may also delete all the YAML files that were generated by Render from your repository.

🎉 Congratulations! You have successfully migrated from Render to Heroku. Woo wee! I hope this guide proves helpful to you, and feel free to share it with anyone who may encounter similar challenges. Also, don't forget to check out —it's up and running.

ruby on rails

receipt scanner



receipt ai

Related Articles

Start uploading Receipts using SMS.

Save 97% of your time with efficient receipt processing

Works with Xero and QuickBooks

Perfect for businesses, big and small

No extra app downloads. Works with tools you already have (Email and SMS)

Start texting receipts →
A working professional traveling at a client site smiles as he takes a photo of a receipt with his smartphone. He plans to upload the receipt using SMS and Receipt-AI, which is integrated with Xero or QuickBooks, while sitting in a cozy café environment. Indicating the ease of using the app.

Receipt-AI with AI and SMS

What's new? Accounting Tips, Product News & Stories

2024 Receipt AI - Big Green Company Terms Privacy