Published: Mar 21, 20213 min read

How to Setup a Free PostgreSQL database on Railway

Written by: Ekom Enyong — Cover Photo by: Heye Jensen on Unsplash

This post was originally published on March 23, 2021, then updated and republished on January 03, 2023.

Nearly two years ago, I discovered Railway. At that time, I was looking for an alternative to Heroku, and I even stated in my original blog post that "Heroku wasn't going anywhere soon." A couple of years later, that is still true; however, Heroku no longer offers free plans.

While I still utilize services like Digital Ocean or AWS for hosting more complex projects, I love how quickly you can get started with a Railway database.

It can be hard to justify paying for cloud databases for beginners or self-taught developers like myself who want to utilize them for learning and hobby purposes. Over the past two years, Railway has updated its pricing structure but still provides a free tier for hobby developers.

Are Free Railway Databases Really Free?

Kind of.

Railway allows you to start building quickly by creating a temporary project with 512 MB RAM, 1GB disk, and $5 or 500 hours of usage.

Screenshot of homepage
Railway allows you to create a temporary project without logging in or giving credit card or payment info.

If you are interested in signing up with your email and payment information, you can still get up to 500 hours of usage free, but your other limits will rise to 8GB RAM and 100GB disk.

Setup a Free PostgreSQL Database

Head to Railway's website in your browser. You can start from scratch or with a starter template without entering your credit card information.

Screenshot of options when starting a new project.
Railway gives you plenty of options to start a new project. You can also use one of their starter templates.

Access your database credentials

Once you've initialized your project, your screen will show your project dashboard. If you only need the database URL to connect to your PostgreSQL client, you can click on your project and then click the Connect tab to show your database URL.

Screenshot of Railway database credentials GUI.
Easily copy the database credentials from your dashboard to your project.

Try Railway with Your Next Project

Integrate with Vercel

For any fellow Next.js/Vercel enthusiasts, Railway has a Vercel integration for deployment.

Ingrate with Everything Else

For the rest of you developers, Railway has excellent examples of starter templates for various app builds, including Blitz.js, Deno, Hasura, Flask, Express, and more.

Check out their website or read their documentation to learn more.

This component allows you to set your content's height and width (or border-radius) while it's still loading. This is good for page speed and Core Web Vitals performance.

I would love to hear your comments, revisions, or suggestions on this post. Let's discuss it on Twitter!

Ekom Enyong is an SEO Manager who has spent the last decade helping brands increase leads and organic traffic through digital strategy and high-quality content.