
Blog
Tutorials
Define backup directory and filename
Discover how to deploy, secure, and manage a Supabase self hosted environment. Get our complete guide for Docker, Kubernetes, and production best practices.

Nafis Amiri
Co-Founder of CatDoes
Nov 9, 2025
Supabase Self Hosted: A Complete Guide
Deciding to run a supabase self hosted instance is a big move. You're trading the plug-and-play convenience of a managed service for something far more valuable: total control and flexibility. It’s a deliberate choice for developers and businesses that need to own their data, manage costs tightly, and customize their backend without hitting a paywall.
This path puts you squarely in the driver's seat.
Why Self Host Supabase in the First Place

Managed services are tempting, no doubt. They offer a quick on-ramp and promise low maintenance. But as a project grows and its needs get more specific, the limits of a one-size-fits-all platform start to feel less like a convenience and more like a constraint. This is exactly where a self-hosted Supabase setup begins to shine.
The first and most obvious win is huge cost savings. Supabase Cloud is fantastic for getting an idea off the ground, but the pricing can ramp up fast as your usage climbs. By self-hosting, you sidestep those scaling costs entirely by running the stack on your own hardware, whether that's a cheap VPS, a beefy dedicated server, or your own private cloud.
A November 2025 analysis really puts this in perspective. You can run a solid Supabase backend on a Hetzner VPS with 8 virtual CPUs and 32 GB of RAM for about $50 a month. To get similar specs on Supabase Cloud, you'd be looking at roughly $410 per month. That's an 88% reduction in hosting costs right there.
Gaining Full Control and Data Sovereignty
Money isn't the only reason to make the switch. Self-hosting gives you complete ownership and authority over your data. This is non-negotiable for any app that needs to follow strict data residency laws like GDPR or HIPAA. When you host it yourself, your data lives on your servers, in a location you choose. No third-party access, no compliance headaches.
That control extends to the entire environment. You're free from vendor lock-in and can tweak every single component of the Supabase stack to your liking.
No Artificial Limits: Forget plan-based caps on API requests, database size, or concurrent users. Your only ceiling is the power of your own hardware.
Direct Database Access: You get full, unrestricted access to your PostgreSQL database. This opens the door to advanced tuning, direct data manipulation, and using any PostgreSQL extension you want, not just the ones pre-approved by a managed service. Our guide on choosing a database for a small business covers why this level of access is so critical.
Total Customization: Want to modify the source code? Integrate a niche authentication provider? Go for it. The entire stack is yours to tailor to your app's specific needs.
By self-hosting, you're not just renting a service; you're building an asset. You gain the power to fine-tune performance, roll out custom security protocols, and ensure your backend scales with your business needs, not just your budget.
This autonomy is a massive strategic advantage. It turns your backend from a recurring monthly bill into a flexible, long-term asset that grows right alongside your vision.
For a clearer picture, it helps to see the two options side-by-side. While Supabase Cloud gets you started in minutes, the self-hosted route offers a level of freedom and cost-efficiency that's hard to ignore as you scale.
Supabase Cloud vs Self Hosted at a Glance
Feature | Supabase Cloud (Managed) | Supabase Self Hosted |
|---|---|---|
Setup & Maintenance | Fully managed, instant setup. Handles updates and scaling. | You manage deployment, updates, backups, and security. |
Cost | Usage-based pricing. Can become expensive at scale. | Fixed cost of your infrastructure. Significant savings at scale. |
Control & Customization | Limited to platform features and approved extensions. | Full control over the entire stack. Modify code, use any extension. |
Data Ownership | Data stored on Supabase's infrastructure. | Data resides on your own servers, ensuring full sovereignty. |
Scalability | "Pay-as-you-go" scaling, but with associated cost increases. | Scale is limited only by your hardware. More predictable costs. |
Support | Official support channels available based on your plan. | Community support and your own team's expertise. |
Ultimately, the choice comes down to what you value more: the immediate convenience of a managed service or the long-term control and cost benefits of managing your own infrastructure.
Getting Your Infrastructure Ready for Supabase
A self-hosted Supabase deployment is only as strong as the ground it's built on. Before you can fire up the services, you have to get the environment right. This means picking the right server horsepower and installing the essential software to make sure your setup goes off without a hitch.
Nailing this first step is critical. If you under-provision your server, you're setting yourself up for performance bottlenecks down the road. Over-provision, and you're just burning cash. The goal is to hit that sweet spot that perfectly matches your app's needs.
Choosing Your Server Specs
Your server, which is usually a Virtual Private Server (VPS), will be home to your entire Supabase stack. The resources you'll need are tied directly to what you're building. A small side project has very different demands than a high-traffic production app.
Here are a few rules of thumb I’ve learned from setting these up:
For Development or Small Projects: A server with 2 vCPUs and 4 GB of RAM is a fantastic starting point. It's more than enough to run all the Supabase services smoothly for testing or for apps with a handful of users.
For Production Applications: When you go live, you need more muscle. I’d aim for at least 4 vCPUs and 8 GB of RAM. This setup can comfortably handle moderate traffic and the more complex database queries that come with a real product.
For High-Traffic or Enterprise Use: If you're expecting a flood of users or have intensive background jobs running, you’ll want to scale up significantly. Think 8+ vCPUs and 16+ GB of RAM to keep your backend snappy and stable under serious pressure.
Storage is the other piece of the puzzle. A fast SSD is non-negotiable; it's vital for database performance. I recommend starting with at least 50 GB of storage, but be ready to expand this as your data grows. Remember, a database isn't just text. It holds user info, logs, and maybe even large files if you're using Supabase Storage. Thinking about data structure early on helps. If you're new to this, our article on spreadsheets versus databases is a great primer on managing data effectively.
Installing the Core Software
Once your server is provisioned, it's time to install the software that makes a self-hosted Supabase environment tick. The official, and by far the best, method relies on containerization. This approach neatly isolates every part of the Supabase stack.
You'll need two essential tools:
Docker: This is the engine that runs your containers. It lets you package applications in isolated environments, and each Supabase service (like the database, Auth, and Storage APIs) gets its own container. This makes the whole system clean, modular, and much easier to manage.
Docker Compose: This tool lets you define and run multi-container applications. Supabase gives you a
docker-compose.ymlfile that acts as the blueprint for your entire backend, telling all the individual services how to connect and work together.
Getting these installed on most Linux systems is pretty straightforward.
Getting Docker and Docker Compose set up correctly is the single most important prerequisite. It’s what turns a complex, multi-service architecture into a simple
docker compose upcommand to launch your entire backend.
With these tools installed, you've essentially built the launchpad for your Supabase instance. Your server is prepped, the core dependencies are in place, and you’re ready to tackle the actual deployment. Taking the time to do this prep work now prevents the most common setup headaches and guarantees a stable foundation from day one.
Deploying Supabase with Docker Compose
With your server prepped, it's time for the main event: deploying your supabase self hosted instance with Docker Compose. This is where the blueprint from the Supabase team comes to life, bringing multiple services together into one cohesive backend. Getting this part right is the key to a stable, production-ready setup.
Your journey starts at the official Supabase repository on GitHub. It’s got everything you need, including the docker-compose.yml file and all the configuration templates. The first thing you'll do is clone this repository directly onto your server, giving you a local copy of the entire setup that you can then tailor to your needs.
Initial Configuration and Secrets
Before you can spin up the containers, you have to generate the unique secrets that will lock down your instance. The Supabase repo includes a handy example file, .env.example. Just copy this to a new file named .env and start filling it out with your own keys.
These keys are absolutely critical for securing your backend. You’ll need to generate strong, unique values for:
POSTGRES_PASSWORD: A robust password for your main database user.
JWT_SECRET: This is used to sign JSON Web Tokens for authenticating users. A long, random string is a must.
ANON_KEY and SERVICE_ROLE_KEY: These are your API keys, controlling access for client-side apps and server-side administrative tasks.
You can use any password generator or a quick command-line tool like openssl rand -hex 32 to create these. Whatever you do, never use the default or example values in a production environment.
Customizing the Docker Compose File
The default docker-compose.yml file is built for local development, so we need to make a few tweaks for a live server. The most important change is making sure your data sticks around if the containers restart or get removed.
This is done by setting up persistent storage volumes. By default, Docker might store some data in anonymous volumes that can disappear. To avoid a catastrophe, you need to explicitly map the PostgreSQL data directory to a named volume or a specific path on your host machine.
This small but vital change guarantees your database files are stored safely in the db_data volume, completely separate from the container's lifecycle. You'll want to do the same thing for Supabase Storage to protect any user-uploaded files.
Configuring Essential Services
A production setup needs more than just a database. You'll have to configure an external SMTP provider to handle emails for things like user sign-ups, password resets, and magic links. Inside your .env file, you’ll find placeholders for your SMTP host, port, user, and password. You can use popular services like SendGrid or Mailgun, or even a simple Gmail account to get started.
Another key piece of the puzzle for production is PgBouncer, a lightweight connection pooler for PostgreSQL. It seriously boosts performance by managing a pool of database connections, which stops your app from crushing the database with too many requests at once. The Supabase Docker setup includes it by default, so you just need to make sure it's enabled and configured correctly in your docker-compose.yml.
Setting up persistent volumes and configuring PgBouncer are non-negotiable for a production deployment. Skipping them is a recipe for data loss and terrible performance as your application scales.
To ensure everything goes smoothly, applying effective software deployment best practices is crucial. This includes versioning your configurations and automating deployment steps wherever you can.
The visual below breaks down this core preparation process, from getting the server ready to installing Docker and prepping the config files.
This three-step flow covers the foundational work you need to do before you can confidently launch your Supabase instance.
Launching and Verifying Your Instance
Once all your configurations are in place, firing up the entire stack is as simple as running one command from inside the repository directory: docker compose up -d. The -d flag tells Docker to run everything in detached mode, so the containers will keep chugging along in the background.
Docker will now pull all the required images for each service, including Kong (the API gateway), GoTrue (auth), PostgREST (your REST API), the PostgreSQL database, and more. This might take a few minutes the first time. When it’s done, you can check on everything with docker compose ps to make sure all services are up and running.
After a successful launch, your Supabase instance is live. You can head over to the Supabase Studio dashboard, which usually runs on port 3000, to start managing your database, users, and API settings. This hands-on walkthrough gives you everything you need to launch and manage a production-ready Supabase backend with confidence.
Securing and Maintaining Your Deployment
Getting your supabase self hosted instance live is a huge step, but the real work starts now. A running instance is just the starting line; long-term success comes down to solid security and maintenance habits. Without them, you're leaving your backend exposed.
Think of it as shifting from a builder to an operator. Ignoring this part of the job can lead to data loss, security holes, and ugly downtime. But a well-tended Supabase instance? That becomes a reliable workhorse for your business.
Mastering Secrets and Environment Variables
Your .env file is basically the keys to the kingdom. It's packed with database passwords, API keys, and JWT secrets. How you handle this one file is your first and most important line of defense. The single biggest mistake I see is people accidentally committing this file to a public Git repo, which instantly blows your entire infrastructure wide open.
First thing you do, every time: add .env to your .gitignore file. No exceptions.
If you're working with a team, create a .env.example file instead. It lists all the variables your app needs but with dummy values. This gives new developers a template without leaking anything sensitive. For production, you really should level up and use a dedicated secrets manager like:
HashiCorp Vault: The industry standard for a reason. It's powerful and gives you central control over all your secrets.
AWS Secrets Manager: A no-brainer if your stack is already running on AWS.
Doppler: A really clean, user-friendly platform that makes syncing secrets across environments simple.
These tools don't just store secrets; they provide auditing, access control, and let you inject variables into your Docker environment at runtime. It's a world away from leaving plaintext files sitting on a server.
Implementing a Bulletproof Backup Strategy
Let's be clear: your data is your most valuable asset. A reliable backup strategy isn't optional. When you self-host, you get full control, but that also means you're the one responsible for protecting your data from a server crash, corruption, or a clumsy DELETE query. You can't afford to wing it.
A simple and effective starting point is using pg_dump, the standard PostgreSQL utility, to create regular database dumps. You can completely automate this with a cron job that fires off a script.
For instance, a nightly backup script could look something like this:
This script creates a compressed SQL file of your entire database and tucks it away. But don't stop there. You absolutely must copy these backups to an off-site location, like an S3 bucket or another cloud storage service. That's what saves you if your entire server goes down in flames.
Your backup strategy is only as good as your ability to restore from it. Regularly test your backups in a staging environment to confirm their integrity and practice your restoration procedure. An untested backup is not a backup at all.
Staying Current with Supabase Updates
The team at Supabase moves fast, pushing out updates with new features, performance boosts, and critical security patches all the time. Keeping your self-hosted instance current is non-negotiable for a healthy, secure environment.
The process usually just involves pulling the latest Docker images and giving your containers a quick restart.
Here’s the typical workflow:
Get the latest config: Head to your Supabase Docker directory and run
git pull. This fetches the newestdocker-compose.ymland other config files.Pull new images: Next, run
docker compose pullto download the updated versions of all the Supabase services.Restart everything: Finally,
docker compose up -dwill restart the containers using the fresh images.
One piece of hard-won advice: always test updates in a staging environment first. This is your safety net to catch breaking changes or weird compatibility issues before they hit your users. I'd also recommend watching the Supabase GitHub repository for release notifications so you always know when a new version drops.
Advanced Deployment with Kubernetes
When you're ready to move beyond a single-server setup, Kubernetes is the next logical step. While Docker Compose is fantastic for getting started and for simpler deployments, Kubernetes is what you turn to when you need serious scalability and high availability for a production supabase self hosted instance.
This is the move that transforms your backend from a single point of failure into a resilient, self-healing system that can handle real-world traffic.

The advantages here are huge. Kubernetes can automatically restart crashed containers, scale services up or down based on traffic, and manage complex networking without breaking a sweat. If your app gets a sudden surge of users, Kubernetes handles it. If a single component fails, the system routes around it. You get a truly robust backend without needing to manually intervene.
Translating Docker Compose to Kubernetes Objects
Making the jump from Docker Compose to Kubernetes means learning a new language. You're essentially translating the concepts from your docker-compose.yml file into a collection of Kubernetes resource definitions, which are also written in YAML.
Here’s how the main pieces map over:
Deployments: In Docker Compose, you define a
service. In Kubernetes, each of those services (like GoTrue or PostgREST) becomes aDeployment. A Deployment's job is to ensure a specific number of copies, or replicas, of your application's container are always running. If one crashes, the Deployment Controller automatically replaces it.Services: A Kubernetes
Serviceacts as a stable network endpoint for your Deployments. It gives a group of pods a consistent IP address and DNS name so they can reliably communicate with each other, even as individual pods are created and destroyed.PersistentVolumeClaims (PVCs): Data persistence is critical. Just like you used named volumes for PostgreSQL and Storage in Docker, you'll use
PersistentVolumeClaimsin Kubernetes. A PVC requests storage from the cluster, which then gets mounted into your pods, ensuring your data survives restarts and crashes.
Building enterprise-grade systems often requires a deeper understanding of how these pieces work together. If you're looking to build more robust and scalable solutions, mastering various Kubernetes deployment strategies is a worthwhile investment.
Leveraging Helm Charts for Simplicity
Okay, so writing all those YAML files from scratch for every single Supabase component sounds like a ton of work, and it is. It’s also incredibly easy to make a mistake.
Thankfully, you don't have to. The community has already solved this problem with Helm charts.
Think of Helm as a package manager for Kubernetes. A Helm chart bundles all the Kubernetes resources, configurations, and dependencies needed to run an application like Supabase into one neat, manageable package.
Using a Helm chart simplifies everything. Instead of juggling dozens of YAML files, you just configure a single values.yaml file. This is where you'll define all your secrets, API keys, database passwords, and resource limits.
You’ll find several well-maintained Supabase Helm charts out there, and they usually come with sensible defaults for a production setup. The workflow is refreshingly straightforward:
First, you add the Helm repository that contains the Supabase chart.
Next, you customize the
values.yamlfile with your environment-specific settings.Finally, you run a single command:
helm install my-supabase repository/supabase -f values.yaml.
That one command tells Helm to generate all the necessary Kubernetes manifests from your config and apply them to your cluster. Upgrades are just as easy. Simply update your values.yaml file and run helm upgrade. Helm handles the entire rollout process for you, making your self-hosted Supabase deployment on Kubernetes both repeatable and reliable.
The Bigger Picture of Self-Hosting Trends
Choosing to run a supabase self hosted instance isn't happening in a vacuum. It's actually part of a much larger shift we're seeing across the industry. More and more, developers and companies are consciously moving away from restrictive SaaS platforms. They're looking for something better: more autonomy, deeper customization, and real control over their own infrastructure and data.
This isn't just some niche trend. It's a strategic move away from the limitations of one-size-fits-all cloud services, and the market numbers back it up.
The global self-hosting market was valued at USD 4.62 billion in the U.S. alone in 2025, with projections showing an annual growth of 16.2%. What’s driving this surge? The exact benefits that a tool like Supabase unlocks: serious flexibility and the power to integrate anything. You can dig into the specifics in this comprehensive market report.
Embracing True Technical Freedom
When you self-host, you're not just running a server. You're gaining a real competitive edge. It opens the door for deep integrations with other modern tools, like private AI models or custom automation workflows, letting you build a tech stack that’s perfectly tailored to your needs.
This level of control has a direct impact on everything from performance to your bottom line, a dynamic we've explored in our breakdown of mobile app development costs.
At the end of the day, self-hosting is about giving yourself the freedom to build without limits.
Common Questions Answered
When you're diving into a Supabase self-hosted setup, a few questions pop up time and again. Getting these sorted out early will save you headaches down the road.
One of the biggest is cost. Is it actually cheaper than Supabase Cloud? For small projects and prototypes, the managed cloud service is almost always the more affordable starting point. But once your application starts to scale, the math flips. The fixed cost of your own infrastructure quickly becomes a bargain compared to the usage-based pricing of the cloud version.
Can I Use the Supabase CLI with a Self-Hosted Instance?
Yes, and you absolutely should. The Supabase CLI isn't just a tool for the managed platform; it's essential for a professional workflow with your self-hosted environment. It’s how you’ll handle database migrations, manage different environments, and push changes to your live instance.
To get it working, you just need to link the CLI to your project using its specific URL and API keys. This simple step lets you keep a clean development process: build and test locally, then deploy database changes to production with confidence.
How Do I Handle Supabase Updates?
Keeping your instance updated is one of your most important maintenance jobs. Thankfully, since you're using Docker, the process is pretty straightforward.
Here's the quick rundown:
First, pull the latest configuration changes by running
git pullin your Supabase Docker repository.Next, grab the newest container images with
docker compose pull.Finally, restart everything with the new images by running
docker compose up -d.
Always, always test updates in a staging environment before you touch production. A quick test can be the difference between a smooth update and unexpected downtime from a breaking change.
This simple routine keeps your backend secure and gives you access to all the latest features the Supabase team ships.
Ready to build your app without writing a single line of code? CatDoes is an AI-native platform that transforms your ideas into production-ready mobile apps, complete with a Supabase backend. Get started for free and launch your vision faster than ever before at https://catdoes.com.

Nafis Amiri
Co-Founder of CatDoes



