
Self-hosting Metabase on Ubuntu 24.04 with PostgreSQL
Atakan ÖztarakWant to use Metabase for business intelligence but prefer to keep everything on your own infrastructure? By self-hosting Metabase on Ubuntu 24.04 with PostgreSQL, you get unlimited users, full data privacy, and zero per-seat fees!
Looking for something simpler? If you'd rather skip server management and deploy Metabase in under 2 minutes for €9/month, check out our guide on self-hosting Metabase the easy way using Sliplane.
What is Metabase?
Metabase is one of the most popular open-source business intelligence (BI) tools available. It lets anyone on your team ask questions about your data and get answers in visual formats like charts, graphs, and dashboards. No SQL knowledge required. You can check out the Metabase GitHub repository to see the source code yourself; it has over 40,000 stars.
What is Metabase used for?
Teams use Metabase to turn raw database data into actionable insights. Common use cases include:
- Sales dashboards: track revenue, conversion rates, and pipeline health
- Product analytics: understand user behavior, feature adoption, and retention
- Financial reporting: monitor expenses, margins, and forecasts
- Customer support metrics: measure response times, ticket volume, and satisfaction
- Marketing analytics: analyze campaign performance and acquisition costs
If your team regularly asks "how many users signed up last week?" or "what's our monthly revenue trend?", Metabase is built exactly for that.
Metabase Pricing: Why Self-Host?
Metabase Cloud starts at €85/month for 5 users. That adds up fast as your team grows. Here's how much businesses typically spend on Metabase and its alternatives:
| Service | Starting Price | Users Included | Open Source |
|---|---|---|---|
| Metabase Cloud | €85/month | 5 | Yes (OSS) |
| Tableau Cloud | €70/user/month | Per seat | No |
| Power BI Pro | €10/user/month | Per seat | No |
| Looker | Custom pricing | Per seat | No |
| Self-hosted | ~€3-5/month | Unlimited | Yes |
By self-hosting, you pay only for the server, typically €3-5/month on Hetzner, and get unlimited users, unlimited dashboards, and full control over your data.
Metabase Alternatives
Before committing, it's worth comparing Metabase with other popular alternatives:
- Apache Superset: another open-source BI tool, more technical and SQL-heavy, but very powerful for data engineers
- Redash: lightweight, great for SQL-savvy teams who just need quick dashboards
- Grafana: best for time-series data and infrastructure monitoring, not ideal for business analytics
- Power BI: Microsoft's offering, strong Excel integration but not self-hostable and expensive at scale
Metabase stands out because non-technical team members can use it right away. The "Question" builder lets anyone create charts without writing a single query.
Prerequisites
Follow along this guide to learn how to deploy your own Metabase instance on Ubuntu 24.04 using Docker, PostgreSQL, and Caddy Web server for automatic HTTPS.
Before we start, make sure you have:
- A Hetzner account (or any other cloud provider)
- Basic SSH experience
- An SSH key pair on your local machine
Step 0: Create a Server on Hetzner
First, we need to create an Ubuntu server. Log into your Hetzner Cloud Console and click the Create Resource button in the top right corner.
Click "Create Resource" to start creating your server
Select Server Type
Choose Shared Resources and select Cost-Optimized. For Metabase, the CX23 server (2 vCPU, 4GB RAM, 40GB SSD) is a solid choice at just €2.99/month. Metabase can be memory-hungry, so 4GB RAM is recommended.
Select Cost-Optimized and CX23 server type
Select Location and OS
Choose a location close to your users (e.g., Nuremberg for EU) and select Ubuntu 24.04 as the operating system.
Choose your preferred location and Ubuntu 24.04
Add Your SSH Key
You'll need to add your SSH public key to access the server. On your local machine, copy your public key to clipboard:
# On macOS
pbcopy < ~/.ssh/id_ed25519.pub
# On Linux
cat ~/.ssh/id_ed25519.pub
# Then copy the output
Copy your SSH public key from terminal
In the Hetzner console, click Add SSH Key and paste your public key. Give it a recognizable name.
Paste your SSH key and give it a name
Create the Server
Give your server a name and click Create & Buy now.
Name your server and click Create & Buy now
Get Your Server IP
Once created, you'll see your server's IP address in the overview. Copy this IP - you'll need it to connect via SSH.
Copy your server's IP address
Connect via SSH
Now connect to your server using SSH:
ssh root@YOUR_SERVER_IP
Successfully connected to your Ubuntu server
Step 1: Update Your Server
Once logged in, update the system to ensure it has the latest security patches and updates.
sudo apt-get update
sudo apt-get upgrade -y
Once finished, your server is ready for installing the software.
Step 2: Install and Configure UFW Firewall
Only keep necessary ports open: SSH (22), HTTP (80), HTTPS (443).
Install UFW and configure the firewall as follows:
sudo apt install ufw -y
sudo ufw allow 22 # SSH
sudo ufw allow 80 # HTTP
sudo ufw allow 443 # HTTPS
sudo ufw enable
Check your firewall configuration:
sudo ufw status verbose
Note: Docker can sometimes ignore UFW rules. To tackle this, verify extra settings as explained here.
Step 3: Docker Installation
Docker will be the container system running Metabase. Install Docker by running these commands:
Setup dependencies and Docker's GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Add Docker repository:
echo \
"deb [arch=$(dpkg --print-architecture) \
signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo $VERSION_CODENAME) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Install Docker Engine and compose-plugin:
sudo apt-get install docker-ce docker-ce-cli \
containerd.io docker-buildx-plugin docker-compose-plugin -y
Check installation:
sudo docker run hello-world
If you see the "Hello from Docker!" message, Docker is ready.
Step 4: Installing Caddy for Automatic HTTPS
Caddy simplifies HTTPS configuration since it handles SSL certificates automatically from Let's Encrypt.
Important: Before configuring Caddy with your domain, make sure you have pointed your domain's A record (for IPv4) and AAAA record (for IPv6) to your server's IP addresses. Without proper DNS configuration, Caddy won't be able to issue SSL certificates.
Install Caddy:
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
| sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
| sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy -y
Edit the Caddyfile configuration file:
sudo nano /etc/caddy/Caddyfile
Replace the contents with your domain name for automatic HTTPS:
yourdomain.com {
reverse_proxy localhost:3000
}
Save the file (Ctrl+O, Enter, Ctrl+X) and restart Caddy:
sudo systemctl restart caddy
Step 5: Running Metabase with Docker Compose
We're going to use Docker Compose with PostgreSQL as the application database. First create a directory for Metabase and navigate to it:
mkdir ~/metabase
cd ~/metabase
Create compose.yml:
nano compose.yml
Add the following content:
services:
metabase:
image: metabase/metabase:v0.59.x
container_name: metabase
restart: always
ports:
- "3000:3000"
environment:
MB_DB_TYPE: postgres
MB_DB_DBNAME: metabaseappdb
MB_DB_PORT: 5432
MB_DB_USER: metabase
MB_DB_PASS: CHANGE_ME_TO_A_SECURE_PASSWORD
MB_DB_HOST: postgres
depends_on:
- postgres
postgres:
image: postgres:16
container_name: metabase_postgres
restart: always
volumes:
- metabase_postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: metabase
POSTGRES_PASSWORD: CHANGE_ME_TO_A_SECURE_PASSWORD
POSTGRES_DB: metabaseappdb
volumes:
metabase_postgres_data:
Note: The image version
v0.59.xwas the latest stable release at the time of writing. Check Metabase's DockerHub page for the most recent stable version before deploying.
Make sure to replace CHANGE_ME_TO_A_SECURE_PASSWORD with a strong password in both the metabase and postgres services.
Save the file and deploy Metabase:
sudo docker compose up -d
Docker pulls the Metabase image and runs it in background mode. Metabase takes a minute or two to fully start up as it runs database migrations on first launch.
You can watch the startup progress with:
sudo docker compose logs -f metabase
Wait until you see a message like Metabase Initialization COMPLETE before proceeding.
Step 6: Accessing Your Self-Hosted Metabase Instance
Visit your domain (or server IP) in any web browser. Your Metabase instance should now load the setup wizard. Follow the on-screen steps to create your admin account, set your preferred language, and connect your first data source.
Metabase setup wizard - Create your admin account
After completing the setup, you'll be taken to the Metabase home screen where you can start exploring your data!
Metabase is ready to use! Start exploring your data
Security Recommendations
Public servers should always be secure. The following practices are recommended:
- Regularly apply updates and security patches.
- Set strong passwords and control user access.
- Monitor server logs for suspicious activity.
- Keep your Docker images updated.
- Set up regular backups of your PostgreSQL volume. Check out our guide on 4 Easy Ways to Backup Docker Volumes for backup strategies.
Updating your Metabase Installation
Since we're using a specific version tag (v0.59.x), you'll need to manually update the tag when a new version is released.
- Check for new versions on Metabase's DockerHub page
- Update the image tag in your
compose.ymlfile (e.g., changev0.59.xto the new version) - Pull and restart:
cd ~/metabase
sudo docker compose pull
sudo docker compose up -d
Docker will download the new version and replace your current container. Your data is safe in the PostgreSQL volume.
Tip: If you prefer automatic updates and don't mind potential breaking changes, you can use the
latesttag instead of a specific version. However, using specific version tags is recommended for production environments as it gives you more control over updates.
Cost Comparison with Cloud BI Tools
Self-hosting Metabase typically results in massive savings compared to cloud BI services:
| Service | Monthly Cost | Users Included | Self-Hostable | Data Location |
|---|---|---|---|---|
| Metabase Cloud | €85+ | 5 | Yes (OSS) | US/EU servers |
| Tableau Cloud | €70/user/mo+ | Per seat | Complex | Vendor servers |
| Power BI Pro | €10/user/mo+ | Per seat | No | Azure |
| Hetzner (self-hosted) | ~€3-5 | Unlimited | Yes | Your servers |
Cost Comparison with Managed Hosting Platforms
If you prefer managed hosting over self-hosting, here's how the costs compare:
| Provider | vCPU Cores | RAM | Disk | Estimated Monthly Cost |
|---|---|---|---|---|
| Render.com | 1 | 2 GB | 40 GB | ~€35-€45 |
| Fly.io | 2 | 2 GB | 40 GB | ~€20-€25 |
| Railway | 2 | 2 GB | 40 GB | ~€15-€66* |
| sliplane.io | 2 | 2 GB | 40 GB | ~€9/month flat |
*Note: Railway charges for actually used memory and CPU time. €66 is the max price, actual price might vary.
With self-hosting on Hetzner (as shown in this guide), you can get similar specs for just ~€3/month, but you're responsible for all the setup and maintenance. Managed platforms handle that for you at a higher price point.
Troubleshooting
Metabase container won't start
Check the logs for errors:
sudo docker compose logs metabase
Common issues include insufficient memory (Metabase needs at least 2GB RAM) and incorrect database credentials.
Can't access Metabase from browser
- Make sure your firewall allows ports 80 and 443
- Verify Caddy is running:
sudo systemctl status caddy - Check if Metabase is running:
sudo docker compose ps - Ensure your DNS is pointing to your server's IP address
- Give Metabase a couple of minutes to finish starting up. The initial boot can take some time
SSL certificate issues
Caddy automatically handles SSL certificates, but if you're having issues:
- Make sure your domain DNS is properly configured
- Check Caddy logs:
sudo journalctl -u caddy - Ensure ports 80 and 443 are open and not blocked by your hosting provider
FAQ
Is Metabase free?
Yes! The Open Source edition is completely free to self-host. You only pay for the server infrastructure. Metabase also offers paid "Pro" (€85/month) and "Enterprise" (custom pricing) plans that add features like advanced embedding, audit logs, SSO, and official support.
Is Metabase down? How do I check?
If you're self-hosting, Metabase availability depends entirely on your own infrastructure. Check your container status with sudo docker compose ps and logs with sudo docker compose logs metabase. If you're using Metabase Cloud, check their status page.
How much do businesses spend on Metabase?
It depends on the deployment method. Metabase Cloud starts at €85/month for 5 users and goes up from there. Self-hosting on a VPS like Hetzner costs as little as €3-5/month for unlimited users. With a managed platform like Sliplane, you can get Metabase running for €9/month flat.
Can I use Metabase with PostgreSQL?
Absolutely, and that's exactly what this guide covers. PostgreSQL is the recommended database for Metabase's application data in production environments. It's more reliable and performant than the default H2 database. Metabase can also connect to PostgreSQL (and many other databases) as a data source for your dashboards.
Why use PostgreSQL instead of the default H2 database?
The default H2 database is fine for testing but not suitable for production. It can corrupt under heavy load and doesn't support easy backups. PostgreSQL gives you data durability, better performance, and straightforward backup strategies with tools like pg_dump or Docker volume backups.
Now you have your own self-hosted Metabase instance running on Ubuntu 24.04 with PostgreSQL! Connect your data sources and start building dashboards.
If managing and securing your own server is a bit too much for you, check out how easy it is to deploy a managed instance of Metabase on Sliplane - it takes just 2 minutes!
Not sure if Metabase is the right tool for your team? Take a look at our comparison of 5 open-source Metabase alternatives to see how it compares to Apache Superset, Redash, Lightdash, and more.
Cheers, Atakan