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:
- Budget Setup: A minimalist $4/month VPS with manual deployment - perfect for small projects or learning
- 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
-
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
-
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
Step 2: Setting Up Your Domain and SSL
-
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
-
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
-
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
-
Generate SSH Key for GitHub:
ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/id_ed25519_github cat ~/.ssh/id_ed25519_github.pub
-
Add the SSH Key to GitHub:
- Go to GitHub Settings → SSH and GPG keys
- Add the new key with a descriptive name
-
Configure SSH for GitHub:
nano ~/.ssh/config
Add:
Host github.com HostName github.com User git IdentityFile ~/.ssh/id_ed25519_github
-
Clone Your Repository:
git clone [email protected]:username/repository.git cd repository
Step 4: Running Your Application with PM2
-
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
-
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
-
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:
- Coolify Control Plane: A small VPS (CAX11 - ~$5/month) to run Coolify itself
- 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

Step 2: Install Coolify
-
SSH into your Coolify VPS:
ssh root@coolify-server-ip
-
Run the Coolify Installer:
wget -q https://get.coolify.io -O install.sh && bash ./install.sh
-
Access the Coolify Dashboard:
- Open a browser and navigate to
http://coolify-server-ip:8000
- Complete the initial setup process
- Open a browser and navigate to

Step 3: Connect Your Deployment Server
-
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
-
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
-
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
-
Configure Domains and SSL:
- Add your custom domain in the application settings
- Coolify will automatically handle SSL certificate issuance
-
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?
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