Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
Blog

How to Self-Host Metabase With Docker on a VPS

A production-focused walkthrough for running the official Metabase Docker image on a VPS, connecting it to PostgreSQL, securing it behind HTTPS and operating it safely.
Length11 min Posted Quest giverVGSources Team

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable production pattern is to run the official metabase/metabase Docker image on a Linux VPS, store Metabase’s application state in PostgreSQL, and publish it through an HTTPS reverse proxy. The container listens on port 3000 internally, while the proxy handles the public hostname and TLS. Keep port 3000 private, store credentials as secrets, and back up the PostgreSQL application database before calling the deployment production-ready.

This guide takes you from an empty VPS to a working, maintainable installation. It uses an external PostgreSQL server in the main example, but the same Metabase container can connect to PostgreSQL running on the VPS or on a managed database service.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What the production setup looks like

A self-hosted installation has four separate responsibilities:

  • VPS and operating system: provides the public IP address, firewall, Docker Engine and storage.
  • Metabase container: runs the application from the official metabase/metabase image.
  • PostgreSQL application database: stores Metabase users, questions, dashboards, permissions and configuration. This is separate from the databases you analyze.
  • Reverse proxy: receives HTTPS traffic for your domain and forwards it to Metabase on the private port 3000.

Metabase’s quick start maps host port 3000 to container port 3000. That is useful for a first test, but a public deployment should treat 3000 as an internal service port. Bind it to localhost or a private network, then allow only the reverse proxy to reach it.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses | Anti UV Ray, For Computers & Gaming, Square Frame, Eyewear for Men and Women
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Why embedded H2 is not a production database

The image can start with an embedded H2 database for evaluation. H2 data lives with the container’s writable filesystem. Removing or replacing that container can therefore remove Metabase’s application data. H2 is appropriate for a disposable trial, not for a deployment whose configuration and user data must survive upgrades, crashes or a rebuilt VPS.

Use PostgreSQL for the Metabase application database. Start with an empty database: Metabase creates its own tables during startup. Do not point Metabase at a database that contains unrelated application tables unless you have explicitly planned that arrangement and isolation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the operating model before installing

Approach Control and data location Who operates backups, networking and upgrades? Typical complexity
Docker on your VPS You control the host, container, proxy and data placement. You are responsible for PostgreSQL protection, TLS, firewall rules, upgrades and rollback. More operational work, but flexible and portable.
Docker with managed PostgreSQL The Metabase container remains on your VPS; PostgreSQL is operated by a database provider. You still manage Metabase, proxy and secrets; the provider supplies database operations according to its service terms. Less database maintenance, but you must configure network access and certificate validation.
Metabase Cloud The service provider operates the application infrastructure. The provider handles the platform; you configure the account and data connections. Easiest operational path, with less host-level control.

Docker on a VPS is the right fit when you need control over deployment location, networking or data residency and can own the maintenance work. There is no universal VPS size or performance number: choose capacity from the number of users, query concurrency, dashboard complexity and the databases being queried, then monitor actual resource use.

Prerequisites

Prepare these items before running the container:

  • A current Linux VPS with a public IP address and enough disk space for the operating system, Docker images, logs and any locally hosted database.
  • A DNS name whose address points to the VPS. Use the final hostname you intend to publish, such as analytics.example.com.
  • Administrative SSH access and a host firewall. In the normal arrangement, expose SSH only to trusted addresses and expose HTTPS publicly; do not expose Metabase’s port 3000 to the internet.
  • Docker Engine and the Docker Compose plugin installed from the instructions for your Linux distribution.
  • An empty PostgreSQL database, either on the VPS or on a reachable managed PostgreSQL service.
  • A plan for TLS certificates, PostgreSQL backups and recovery testing.

Keep the VPS operating system and Docker packages updated. Before an upgrade, make sure you can restore the PostgreSQL application database and that you have a known-good image version to roll back to.

Create the PostgreSQL application database

Create a dedicated database and login for Metabase. The database can be empty; Metabase creates its schema on first startup. A typical set of values is:

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
  • Database name: metabaseappdb
  • Port: 5432, unless your PostgreSQL service uses another port
  • Dedicated username and a long, unique password
  • Hostname or private address reachable from the VPS

Grant the Metabase login the permissions required to create and update tables in this database. Do not reuse a superuser credential when a scoped account is sufficient. If PostgreSQL is on another network, allow connections from the VPS address only and require TLS according to the provider’s instructions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a provider-hosted database, collect its CA certificate and connection requirements before starting Metabase. The Docker image includes AWS and Azure CA certificates under /app/certs/. Connections to other services may require a custom image or mounted certificate files.

Create a private Docker project

Make a directory that is writable by the administrator but not served by the web server:

sudo mkdir -p /opt/metabase
sudo chown $USER:$USER /opt/metabase
cd /opt/metabase
mkdir -p secrets

Store the database username and password in files with restrictive permissions. Replace the example values with your real credentials:

umask 077
printf '%s' 'metabase_user' > secrets/mb_db_user
printf '%s' 'replace-with-a-long-random-password' > secrets/mb_db_pass
chmod 600 secrets/mb_db_user secrets/mb_db_pass

Do not commit these files to source control or paste the password into a public issue. Docker Secrets or a dedicated secret manager is preferable on a multi-operator system; the file-based Compose example below keeps the credentials out of the Compose YAML while remaining easy to understand.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Define the Metabase container with Compose

Create /opt/metabase/compose.yml. The image tag is deliberately explicit so that an upgrade is a controlled change rather than an accidental pull of a moving latest tag. Substitute the current version you have approved for your environment.

services:
  metabase:
    image: metabase/metabase:<approved-version>
    container_name: metabase
    restart: unless-stopped
    ports:
      - 127.0.0.1:3000:3000
    environment:
      MB_DB_TYPE: postgres
      MB_DB_DBNAME: metabaseappdb
      MB_DB_PORT: 5432
      MB_DB_HOST: <database-host>
      MB_DB_USER_FILE: /run/secrets/mb_db_user
      MB_DB_PASS_FILE: /run/secrets/mb_db_pass
      MB_SITE_URL: https://analytics.example.com
      MB_REDIRECT_ALL_REQUESTS_TO_HTTPS: 'true'
    secrets:
      - mb_db_user
      - mb_db_pass
    healthcheck:
      test: ['CMD-SHELL', 'curl --fail http://localhost:3000/api/health || exit 1']
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 60s

secrets:
  mb_db_user:
    file: ./secrets/mb_db_user
  mb_db_pass:
    file: ./secrets/mb_db_pass

The important database variables are MB_DB_TYPE=postgres, MB_DB_DBNAME, MB_DB_PORT, MB_DB_USER, MB_DB_PASS and MB_DB_HOST. The official image also supports secret-file forms such as MB_DB_USER_FILE and MB_DB_PASS_FILE; use the forms supported by the image version you have approved. If your secret manager supplies a complete connection string, MB_DB_CONNECTION_URI and its supported file form can be used instead of separate host, port and credential variables.

Binding 127.0.0.1:3000:3000 means only software on the VPS can reach the application directly. If your reverse proxy runs in another container, put both services on a private Docker network and publish no host port for Metabase; the proxy can then forward to the service name metabase:3000.

Start Metabase and complete first-run setup

  1. Validate the Compose file and secret paths:
    docker compose -f /opt/metabase/compose.yml config
  2. Start the container in the background:
    docker compose -f /opt/metabase/compose.yml up -d
  3. Follow startup logs:
    docker logs -f metabase

    Metabase must be able to resolve the PostgreSQL hostname, authenticate and create its tables. The first start can take longer while migrations run.

  4. Check the health endpoint locally:
    curl http://127.0.0.1:3000/api/health

    A healthy response confirms that the HTTP service is responding. A healthy HTTP response alone does not prove that every data source is reachable.

  5. Open the site through the reverse proxy hostname after TLS is configured and finish the setup wizard. Create an administrator account, set the site details and add only the data connections your users need.

If the container exits, inspect both the container log and the PostgreSQL server log. Common causes are an incorrect host name, a blocked database port, a password file with an unintended newline, or a database user that cannot create tables.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Put Metabase behind HTTPS

Metabase’s security guidance recommends placing the application behind a reverse proxy or load balancer that you control and not exposing the application port directly to the internet. The proxy should terminate TLS, redirect HTTP to HTTPS and forward requests to the private Metabase listener.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Reverse-proxy requirements

  • Point the DNS record for your chosen hostname at the proxy’s public address.
  • Obtain and renew a certificate for that hostname.
  • Forward requests to http://127.0.0.1:3000 when Compose binds locally, or to http://metabase:3000 on a shared private Docker network.
  • Preserve the original host and scheme headers so links and redirects use the public URL.
  • Set MB_SITE_URL to the exact HTTPS URL and enable MB_REDIRECT_ALL_REQUESTS_TO_HTTPS=true when TLS terminates at the proxy.

Example Nginx server block

The following illustrates the forwarding settings. Replace the certificate paths and hostname with the values managed by your certificate process:

server {
    listen 80;
    server_name analytics.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name analytics.example.com;

    ssl_certificate /etc/ssl/analytics/fullchain.pem;
    ssl_certificate_key /etc/ssl/analytics/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
    }
}

Reload the proxy only after its configuration passes the proxy’s syntax check. Test both an HTTP request, which should redirect, and an HTTPS request, which should load the setup or sign-in page. Keep port 3000 closed in the VPS firewall and in any cloud security group.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Protect credentials and data connections

There are two different classes of credentials: the credentials Metabase uses for its own PostgreSQL application database and the credentials for databases that users query. Protect both.

  • Keep application-database passwords in Docker Secrets or an equivalent secret manager, not in a committed Compose file.
  • Use separate database users for separate data sources and grant the least privilege needed for reporting.
  • Enable certificate validation and TLS for PostgreSQL and connected data sources whenever the service supports it. Follow the database provider’s certificate instructions rather than disabling verification to make a connection work.
  • Restrict network paths so PostgreSQL accepts connections from the Metabase host or private network, not from the entire internet.
  • Rotate credentials through your secret mechanism and restart the container when the application must reread a changed secret.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Backups, upgrades and rollback

Back up the PostgreSQL application database

The application database contains the Metabase configuration that makes a deployment useful. Schedule regular PostgreSQL backups and store them separately from the VPS. A backup is not an operational plan until you have restored it to an isolated PostgreSQL instance and confirmed that Metabase can start against the restored copy.

Record the backup schedule, retention period, encryption method and the person or system responsible for checking failures. If PostgreSQL is managed, verify what the provider’s automated backups cover and whether you can download or restore them independently.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Upgrade with a controlled image tag

  1. Read the release notes for the Metabase version you intend to run and check compatibility with your database and deployment process.
  2. Take and verify a fresh PostgreSQL backup.
  3. Record the currently running image tag:
    docker inspect --format '{{.Config.Image}}' metabase
  4. Change only the image tag in compose.yml, then pull and recreate the service:
    docker compose -f /opt/metabase/compose.yml pull metabase
    docker compose -f /opt/metabase/compose.yml up -d metabase
  5. Watch the logs, health endpoint and representative dashboards. Keep the previous image tag available until the new version is accepted.

If the new container fails, stop it, restore the prior image tag and follow your tested database-restore procedure if a migration has made a downgrade unsafe. Do not delete the PostgreSQL application database as a troubleshooting shortcut.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Firewall and host hardening checklist

  • Allow SSH only from trusted administrative addresses where practical.
  • Allow TCP 443 for public HTTPS and TCP 80 only when it is needed for HTTP-to-HTTPS redirects or certificate issuance.
  • Do not allow public access to TCP 3000 or PostgreSQL’s TCP 5432.
  • Apply operating-system security updates and remove unused services.
  • Keep Compose files, secret files and proxy private keys readable only by the accounts that need them.
  • Send container and proxy logs to your normal monitoring and retention system.
  • Set an alert for a failed health check, repeated container restarts, low disk space and failed backups.

Troubleshooting by symptom

The container repeatedly restarts

Run docker logs metabase. A database authentication error usually means the username, password file, host or port is wrong. A connection timeout indicates firewall, routing or DNS trouble. A permission error during startup means the PostgreSQL login cannot create or alter the Metabase schema.

The browser shows a gateway timeout

Confirm that the container is healthy with curl http://127.0.0.1:3000/api/health. If that works, inspect the proxy’s upstream address, firewall rules and SELinux or AppArmor policy. If the container is bound to localhost, a proxy in another container cannot use 127.0.0.1; place both containers on a private Docker network and use the Metabase service name.

Redirects point to HTTP or the wrong hostname

Set MB_SITE_URL to the complete HTTPS URL, pass X-Forwarded-Proto https from the proxy and enable MB_REDIRECT_ALL_REQUESTS_TO_HTTPS=true when TLS ends at the proxy. Clear a cached redirect in the browser after correcting the configuration.

Metabase starts but a data source cannot connect

Test DNS and network reachability from the Metabase container, then verify the data-source login and TLS certificate chain. The application database connection and each queried data source are separate connections; a healthy Metabase status does not guarantee that every source is available.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The site worked until the container was removed

If the deployment used embedded H2, its application data was tied to the container filesystem. Recreate the deployment with PostgreSQL, restore any available H2 backup if one exists, and do not use the disposable H2 mode for ongoing operations.

When a VPS deployment is the wrong choice

Choose a hosted option when your team cannot provide on-call ownership for patching, backups, TLS renewal and incident recovery. Choose a VPS when those responsibilities are acceptable and you need control over where the application runs, how it connects to internal databases or how upgrades are scheduled. The decision is operational rather than a performance guarantee: neither the official documentation nor this deployment pattern supplies a universal throughput, uptime or cost figure.

Go-live checklist

  • Metabase runs from an approved, reviewable image tag.
  • Its application database is PostgreSQL, not embedded H2.
  • PostgreSQL credentials are supplied through secrets and are not committed to source control.
  • The database is reachable only over the intended private path and uses TLS validation where supported.
  • The public hostname resolves correctly and serves a valid HTTPS certificate.
  • MB_SITE_URL is the HTTPS hostname and HTTP requests redirect to HTTPS.
  • Port 3000 is private; only the reverse proxy reaches it.
  • Backups run on schedule, and a restoration test has succeeded.
  • An upgrade and rollback procedure identifies the current image tag and preserves a known-good database backup.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.