Migrating my Django app from Heroku to Railway

Migrating my Django app from Heroku to Railway

Heroku closes all of its free services. What should we do with our existing hosted projects on Heroku? Let's discuss it!

Heroku is slowly closing all its free services from 28th November. My free deployments were also removed. So, let's migrate them from Heroku.

What is Heroku?

Heroku is one of the most popular cloud PaaS (Platform as a Service) platforms. If you are a full-stack developer and didn't hear or listened about Heroku, then you are rare. But some months ago, Salesforce (the Parent Organization of Heroku) and Heroku changed their policy and decided that they were going to close all their free services.

Message from Heroku

As we previously communicated, starting November 28th, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis® will no longer be available. You must take action to continue to operate your applications on our service and prevent the deletion of your free databases.

Fun Fact

I thought that Heroku would not remove my small apps after noticing my app was running after 28th November😀, but after 1st December, my deployment was removed.🙃 I think they slowly removing their free services. Heroku hosted different open-source projects, also migrating from Heroku.

Below is the current condition of all of my Heroku Deployed projects.

What should we do now?

We should migrate our apps from Heroku. Thankfully there are a lot of alternatives to Heroku, some of which are better than Heroku. In this article, I will explain how we can move/migrate our Heroku-hosted website from Heroku to Railway. It's pretty simple. I have been using Railway for several days, and I love it. It is user-friendly, and its UI/UX is also excellent.

Migrating to Railway

Go to https://railway.app/, and you will see a beautiful user interface.

image.png

First, we must log into the Railway to access the Railway dashboard. I will recommend Login in using Login with GitHub as we will deploy our project from GitHub Repository.

image.png

After clicking the GitHub button, you have to give Railway permission to access your GitHub Repositories. There will be two options, you can select All Repositories or only One Repository. You can select any option and click the "Authorize" button to connect Railway with GitHub.

After successful login, you will see an empty dashboard; I have already created a project for myself.

You can also create a project by clicking on the "New Project" button. After clicking the "New Project" button, you will see a page like the one below.

I want to deploy my project from GitHub, so I am clicking on "Deploy from GitHub repo." Then you will see the list of your GitHub Repos. Search for the Repo you want to deploy, and you will find it. My Repo name is "NewsHub." This is a News Aggregator/Scraper site built with python Django.

Click on your Repo name and you will see this "Deploy Now" button.

Click on the "Deploy Now" button to start the deployment process.

After a few minutes, you will see that your app has been deployed successfully. The railway can read Heroku profile, you can see that it has read my service from my profile in the GitHub Repo.

You can also change the domain name from settings.

And don't forget to add your domain to your ALLOWED_HOSTS list or any other related place.

Yeah!🎉 My Railway App is now up and running. It feels like it is loading faster than Heroku.🚀

Railway CLI

Now, if you want to work locally and deploy from your terminal like Heroku CLI, don't worry. Railway also has Railway CLI, which is easier to use than Heroku. I will try to write another article by showing you how you can use Railway CLI for running your projects. Till then, you can read their documentation, their documentation is pretty clear too.

https://docs.railway.app/develop/cli

Final Words

I only discuss a few features of the Railway, but Railway has so many built-in templates and exciting features which you should definitely try. They are also helping good Open Source Projects.

If you find this article helpful, feel free to follow me on Hashnode and GitHub.

My GitHub Profile: https://github.com/musfiqdehan

Thanks for reading this article. Any feedback is welcome.😊