Let’s see some options to host your PostgreSQL database
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.
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, but you can find many tutorials for your Operating System by searching “install postgresql on
This is important: the local database would only work on localhost, as your computer is not accessible from the Internet, so the moment you want to deploy on Vercel or Netlify or anywhere else that’s publicly accessible, you will need to create a new remote database.
All the other options listed below will not have this problem, all of them will be accessible from anywhere on the Internet.
Railway is a good option to get up and running very quickly with a remote database.
It’s free to start and they have no limits on the number of projects you can create.
The problem is that you can exceed the free plan limits after working on a few projects, so after a while you will have to pay or your applications will not work.
It has a nice user interface, it’s simple, but it can be a bit slow in the free plan (of course, as they have to “cut” somewhere on the expenses)
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 setup a Linux server. And manage it. Skip this option if this does not excite you, because it can be a real pain and time sink.
TIP: DigitalOcean also offers a managed database that makes things easier (but also costs more, save time spend more), see below.
They have some great guides for that on the DigitalOcean docs:
How To Install PostgreSQL on Ubuntu 20.04 [Quickstart] | DigitalOcean
NOTE: I say DigitalOcean because I use and like that platform (and you can use my referral link to get a $100 free credit you can use for the next 2 months) 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 Next.js app on there. This has a benefit: both the app, and the data, will be on the same server.
For all the other options, your data will sit “somewhere in the cloud” and your database will be “somewhere else on the cloud” and this has a cost in terms of speed.
And you can scale up the capabilities of the server as you need, so your $5 VPS will cost more, but it will also be much more performant as needed.
DigitalOcean Managed Database
I already talked about DigitalOcean in terms of hosting your own VPS.
This is different - they host the database without you having to setup or maintain anything.
I think this is a great solution to host all your applications without incurring extra costs (Railway) and have peace of mind as you do not have to worry about your server, maintenance, being hacked, etc.
This is a costly solution but is convenient for this reason (and you can use my referral link to get a $100 free credit you can use for the next 2 months). The interesting thing is that you pay by the hour, so you can test it and then shut it down.
They provide great features like daily backups, they have connection pooler, which helps not exhausting the database connection limit with Prisma.
FREE FOR 2 PROJECTS
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 they offer a free connection pooler, which helps not exhausting the database connection limit with Prisma.
They allow up to 2 projects in the free account, so it’s worth trying it. You can also work on a new project, then delete the old ones once you’re done.
Supabase markets itself as a Firebase alternative, and in addition to the database you have authentication, subscriptions, and a lot more you can explore later on.
NOTE: Supabase can also be self hosted, so your 2 projects limit will disappear, at the expense of having to manage your own infrastructure
AWS RDS for PostgreSQL
An optimal solution if you’re already using AWS. The free tier of AWS should include this for your first year.
This is a bit more complex to setup 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.