Where to host a PostgreSQL database

By

Where to host a PostgreSQL database, from a local dev setup to a VPS or a managed service, and how to weigh the operational work each option demands.

~~~

When it comes to hosting the PostgreSQL database for your app you have many choices, and which one is perfect for you depends on your skills, your willingness to trade time for money (hosted solution or self-hosted solution), and your preferences.

If you want to start without paying, I built a free free tier finder that lists all the $0 plans (databases included) filtered by what your app needs.

Before the list, one framing that makes the decision easier. A managed provider normally handles installation, patching, monitoring, backups, and failover. You still own schema changes, queries, access control, capacity, and restore testing — no provider knows your data. Self-hosting gives more control and a lower bill, but upgrades, storage, replication, security, and recovery become your job. Choose the operational work you are prepared to perform, not only the feature list.

Local database

FAST FREE REQUIRES SETUP LIMITED TO LOCALHOST

A local database is your best choice when you are developing your application on localhost.

Your application will be very fast on localhost if you use a local database, because the app does not need to look for the data on the Internet.

The drawback is the initial setup. I have a guide for macOS, and the official downloads cover Windows and Linux.

This is important: the local database only works on localhost, as your computer is not accessible from the Internet. The moment you deploy anywhere public, you need a remote database. All the options below are reachable from anywhere.

FAST TO START NO SETUP USAGE-BASED PRICING

Railway is a good option to get up and running very quickly with a remote database.

You click a button, you get a PostgreSQL instance and a connection URL. The pricing is usage-based, so a small side project costs little, but check the current plan limits before depending on it — entry-level plans on platforms like this change over time.

It has a nice user interface and it’s simple, which is exactly what you want while validating an idea.

DigitalOcean VPS

CHEAP REQUIRES SETUP YOU OPERATE IT

This is one of the best options when it comes to having your own server, with your own database, on the Internet.

The drawback is that you’ll need to learn how to set up and manage a Linux server: securing it, applying updates, watching disk space, planning major-version upgrades, and rehearsing restores. Skip this option if this does not excite you, because it can be a real time sink. If it does excite you, it is also the best teacher.

TIP: DigitalOcean also offers a managed database that makes things easier (but also costs more, save time spend more), see below.

DigitalOcean has great setup guides in its docs, like How To Install PostgreSQL on Ubuntu.

NOTE: I say DigitalOcean because I use and like that platform (and you can use my referral link to get free credit) but you could use any other VPS company.

The plus side is that if you have your own VPS for the database, you can also host the app on there. Both the app and the data live on the same server, which removes network latency between them. And you can scale up the server as you need.

DigitalOcean Managed Database

PAID NO SETUP BACKUPS INCLUDED

I already talked about DigitalOcean in terms of hosting your own VPS.

This is different - they host the database without you having to set up or maintain anything.

I think this is a great solution to host all your applications and have peace of mind, as you do not have to worry about your server, maintenance, being hacked, and so on. You pay by the hour, so you can test it and then shut it down.

They provide daily backups and a connection pooler, which helps when your platform runs serverless functions that would otherwise exhaust the database connection limit.

One thing no managed provider does for you: proving the backups restore into something your app can use. Restore one into a scratch database once in a while and point the app at it.

Supabase

FREE TIER CONNECTION POOL NO SETUP

Supabase is a very interesting project. It’s not “just a database hosting” but it’s also one, so you can use it as that. It’s an app development platform built on top of PostgreSQL, and it includes a connection pooler, again useful with serverless platforms.

The free tier is enough to try it seriously. Supabase markets itself as a Firebase alternative, and in addition to the database you have authentication, realtime subscriptions, storage, and a lot more you can explore later on.

NOTE: Supabase can also be self hosted, at the expense of having to manage your own infrastructure

AWS RDS for PostgreSQL

PAID NO SETUP COMPLEX

An optimal solution if you’re already using AWS, and the AWS free tier can cover a small instance for the first year.

This is a bit more complex to set up than the other hosted solutions, being AWS, but it’s also a managed solution, so you don’t need to worry about managing your own server.

Like for DigitalOcean, you could also use AWS EC2 to host your VPS on Amazon AWS, and install PostgreSQL on that.

How I’d decide

For development, local. For a first deployment, a managed option with a connection pooler, because the operational work you skip is worth more than the price difference. Self-host on a VPS when you either want to learn server administration or you have enough traffic that the managed premium starts to matter — and in that case, budget real time for backups and upgrade drills, because whoever hosts it, the restore test is always yours.

Tagged: Database · All topics
~~~

Related posts about database: