Join our new Affiliate Program!
    Self-Hosting Your Projects with Hetzner in 2025

    infrastructure

    hetzner

    self-hosting

    Self-Hosting Your Projects with Hetzner in 2025

    Why Self-Host in 2025?

    In an era of expensive cloud services and "serverless tax," self-hosting has become increasingly attractive for developers and small businesses. With a Virtual Private Server (VPS) from Hetzner, you can host multiple web applications for a fixed monthly cost, maintaining complete control over your infrastructure.

    Self-hosting means running your applications on servers you manage rather than using managed cloud services. While it requires more technical knowledge, it offers greater flexibility, potential cost savings, and freedom from vendor limitations.

    Two Approaches to Self-Hosting

    This guide presents two approaches to self-hosting on Hetzner:

    1. Budget Setup: A minimalist $4/month VPS with manual deployment - perfect for small projects or learning
    2. Scalable Solution: A more robust setup using Coolify as a deployment platform - ideal for managing multiple applications

    Let's explore both options and help you decide which is right for your needs.

    Approach 1: Budget Self-Hosting ($4/month)

    This approach is perfect for developers looking to host a single application or experiment with self-hosting without significant investment.

    Step 1: Setting Up Your Hetzner VPS

    1. Register on Hetzner Cloud:

      • Create an account at Hetzner Cloud
      • You can register quickly with PayPal for payment
      • Use a company email rather than personal if possible
    2. Select a Server:

      • Choose the CX11 plan ($4/month) with 1 vCPU, 2GB RAM, and 20GB storage
      • Select Ubuntu as your operating system
      • Add your SSH key during setup (generate one with ssh-keygen if needed)
      • After creating the server, note its IP address
    Server rack

    Step 2: Setting Up Your Domain and SSL

    1. Configure DNS with Cloudflare:

      • Create a Cloudflare account and add your domain
      • Add an A record pointing to your Hetzner VPS IP address
      • Set SSL/TLS to "Full" mode for secure connections
    2. Install Caddy as Web Server:

      # SSH into your server
      ssh root@your-server-ip
       
      # Install Caddy
      sudo apt update
      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
       
      # Start and enable Caddy
      sudo systemctl start caddy
      sudo systemctl enable caddy
    3. Configure Caddy for Your Domain:

      # Edit Caddyfile
      sudo nano /etc/caddy/Caddyfile

      Replace the contents with:

      yourdomain.com, www.yourdomain.com {
        reverse_proxy localhost:3000
      }
      

      Then reload Caddy:

      sudo systemctl reload caddy

    Caddy automatically handles SSL certificate issuance and renewal through Let's Encrypt. No additional configuration is needed for HTTPS.

    Step 3: Setting Up Deployment from GitHub

    1. Generate SSH Key for GitHub:

      ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/id_ed25519_github
      cat ~/.ssh/id_ed25519_github.pub
    2. Add the SSH Key to GitHub:

      • Go to GitHub Settings → SSH and GPG keys
      • Add the new key with a descriptive name
    3. Configure SSH for GitHub:

      nano ~/.ssh/config

      Add:

      Host github.com
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ed25519_github
      
    4. Clone Your Repository:

      git clone [email protected]:username/repository.git
      cd repository

    Step 4: Running Your Application with PM2

    1. Install Node.js and PM2:

      # Install Node.js
      curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
      sudo apt install nodejs
       
      # Install PM2
      sudo npm install -g pm2
    2. Start Your Application:

      # Install dependencies
      npm install
       
      # Start with PM2
      pm2 start npm --name "your-app" -- start
       
      # Configure PM2 to start on boot
      pm2 save
      pm2 startup
    3. Updating Your Application:

      # Pull latest changes
      git pull
       
      # Restart the application
      pm2 restart your-app

    This budget setup is perfect for personal projects, portfolio sites, or small applications. For about $4 per month, you get a fully functional server with automatic SSL, reliable hosting, and simple deployment.

    Approach 2: Scalable Self-Hosting with Coolify

    This approach is ideal for developers managing multiple applications or requiring more resources for AI applications, databases, or higher traffic.

    As your needs grow, you might find yourself needing a more organized approach to manage multiple applications. This is where Coolify comes in - an open-source, self-hosted Heroku/Netlify/Vercel alternative.

    Step 1: Choose the Right Hetzner Servers

    For a robust Coolify setup, you'll need two VPS instances:

    1. Coolify Control Plane: A small VPS (CAX11 - ~$5/month) to run Coolify itself
    2. Deployment Server: A larger VPS based on your needs:
      • CAX21 (~$10/month): Good for multiple smaller applications
      • CAX31 (~$20/month): Better for resource-intensive apps or AI workloads
      • Dedicated server (~$40/month): For serious workloads, consider Hetzner's server auction for refurbished servers with great specs
    Hetzner console

    Step 2: Install Coolify

    1. SSH into your Coolify VPS:

      ssh root@coolify-server-ip
    2. Run the Coolify Installer:

      wget -q https://get.coolify.io -O install.sh && bash ./install.sh
    3. Access the Coolify Dashboard:

      • Open a browser and navigate to http://coolify-server-ip:8000
      • Complete the initial setup process
    Coolify dashboard

    Step 3: Connect Your Deployment Server

    1. Add Your Deployment Server in Coolify:

      • Navigate to the "Servers" section in Coolify
      • Click "Add Server" and enter your deployment server details
      • Coolify will automatically set up the necessary components
    2. Configure GitHub Integration:

      • Go to "Sources" in Coolify
      • Add a GitHub App integration
      • Follow the wizard to authorize Coolify to access your repositories

    When Coolify is connected to GitHub, it can automatically detect changes and deploy your applications whenever you push to your repository.

    Step 4: Deploy Your Applications

    1. Create a New Application:

      • Click "Add Resource" and select the appropriate type (web app, database, etc.)
      • Connect to your GitHub repository
      • Configure build settings based on your application needs
    2. Configure Domains and SSL:

      • Add your custom domain in the application settings
      • Coolify will automatically handle SSL certificate issuance
    3. Monitor Your Deployments:

      • Use the Coolify dashboard to view logs, resource usage, and deployment status
      • Set up notifications for deployment success/failure (supports Telegram, Discord, etc.)

    Why Self-Host Instead of Using Cloud Services?

    Server costs comparison

    Cost Benefits

    Cloud providers like Vercel, Netlify, and Heroku charge based on usage metrics like:

    • Number of applications/services
    • Build minutes
    • Bandwidth
    • Function invocations

    With self-hosting, you pay a fixed price for your hardware regardless of how many applications you run. This becomes increasingly cost-effective as you add more applications.

    Freedom from Limitations

    Self-hosting eliminates common cloud service restrictions:

    • No timeout limits for API routes or serverless functions
    • No bandwidth caps or expensive overage charges
    • No vendor lock-in or proprietary systems
    • Full control over runtime environments and configurations

    Perfect for AI Applications

    For AI and ML applications specifically:

    • Run larger models locally without cloud constraints
    • Avoid cold starts for better performance
    • Customize infrastructure for specific model requirements
    • Keep sensitive data on your own infrastructure

    Self-hosting is particularly valuable for AI applications that may exceed the resource limits of serverless platforms or require longer processing times.

    Conclusion: Choose the Right Approach for Your Needs

    Self-hosting with Hetzner offers a compelling alternative to cloud services, whether you choose:

    • The Budget Approach: $4/month for a simple setup perfect for personal projects
    • The Coolify Approach: $15-40/month for a robust, scalable solution for multiple applications

    Both approaches give you complete control over your infrastructure while avoiding the "serverless tax" of pay-per-use cloud platforms.

    The right choice depends on your specific needs:

    • Starting small? Begin with the budget approach and upgrade later
    • Managing multiple apps? Coolify provides the organization and automation you need
    • Running resource-intensive applications? Hetzner's larger instances or dedicated servers offer excellent value

    Whichever path you choose, self-hosting represents a return to a simpler, more predictable cost model for web development while maintaining full control over your digital presence.

    Fekri

    Fekri

    Related Blogs

    Best SaaS Boilerplates to Build Your App in 2025

    development

    saas

    boilerplates

    Best SaaS Boilerplates to Build Your App in 2025

    A comprehensive comparison of the top SaaS boilerplates to accelerate your development process and get your product to market faster.

    Fekri

    Fekri

    April 01, 2025

    SaaS Payment Providers: The Ultimate Comparison Guide

    payments

    saas

    SaaS Payment Providers: The Ultimate Comparison Guide

    A concise comparison of Stripe, Lemon Squeezy, Polar, and Creem for SaaS businesses looking for the ideal payment solution.

    Fekri

    Fekri

    April 03, 2025

    The best SaaS Boilerplates to build your SaaS in 2024

    development

    saas

    boilerplates

    The best SaaS Boilerplates to build your SaaS in 2024

    Your Ultimate Guide to Speedy SaaS Development

    Fekri

    Fekri

    August 05, 2024

    Build
    faster using AI templates.

    AnotherWrapper gives you the foundation to build and ship fast. No more reinventing the wheel.

    Fekri — Solopreneur building AI startups
    Founder's Note

    Hi, I'm Fekri 👋

    @fekdaoui

    Over the last 15 months, I've built around 10 different AI apps. I noticed I was wasting a lot of time on repetitive tasks like:

    • Setting up tricky APIs
    • Generating vector embeddings
    • Integrating different AI models into a flow
    • Handling user input and output
    • Authentication, paywalls, emails, ...

    So I built something to make it easy.

    Now I can build a new AI app in just a couple of hours, leveraging one of the 10+ different AI demo apps.

    10+ ready-to-use apps

    10+ AI app templates to kickstart development

    Complete codebase

    Auth, payments, APIs — all integrated

    AI-ready infrastructure

    Vector embeddings, model switching, RAG

    Production-ready

    Secure deployment, rate limiting, error handling

    Get AnotherWrapper

    One-time purchase, lifetime access

    $249

    Pay once, use forever

    FAQ
    Frequently asked questions

    Have questions before getting started? Here are answers to common questions about AnotherWrapper.

    Still have questions? Email us at [email protected]