How to Self-Host Forgejo on Hetzner (2026 Guide)
Forgejo is a self-hosted Git service that allows you to manage your repositories seamlessly. It is a perfect choice for developers who want full control over their projects. This guide will walk you through the process of setting up Forgejo on Hetzner, one of the top VPS providers, known for its reliability and affordability.
Why Choose Hetzner for Self-Hosting Forgejo?
Hetzner offers flexible pricing options, robust performance, and high availability. Starting as low as 4.15 EUR/month, you can obtain a VPS with sufficient resources to run Forgejo efficiently. Hereโs a comparison of some top VPS providers:
| Provider | Monthly Cost | CPU Cores | RAM | Storage |
|---|---|---|---|---|
| Contabo VPS | 5.99 EUR | 4 | 8 GB | 200 GB |
| Hetzner Cloud | 4.15 EUR | 1 | 2 GB | 20 GB |
| DigitalOcean | 6 USD | 1 | 1 GB | 25 GB |
| Vultr | 6 USD | 1 | 1 GB | 25 GB |
| Linode | 5 USD | 1 | 2 GB | 50 GB |
Hetznerโs competitive pricing combined with solid performance makes it an ideal choice for self-hosting applications like Forgejo.
Prerequisites
Before you begin, ensure you have:
- A Hetzner account โ Sign up here.
- A freshly created VPS โ For hosting Forgejo, a basic plan with at least 2 GB of RAM is recommended.
Step-by-Step Installation of Forgejo on Hetzner
Step 1: Access Your VPS
Use SSH to connect to your newly created VPS:
ssh root@<your-vps-ip>
Step 2: Update Your System
Once connected, itโs best to update your package repository and upgrade your installed packages. Run the following commands:
apt update && apt upgrade -y
Step 3: Install Required Dependencies
Next, we need to install some necessary packages, including Git, Curl, and Docker. Run:
apt install git curl docker.io docker-compose -y
Enable and start Docker:
systemctl enable docker
systemctl start docker
Step 4: Create Forgejo Configuration
Create a directory for Forgejo:
mkdir -p /opt/forgejo
Now, create a docker-compose.yml file to define the Forgejo service:
version: '3.8'
services:
forgejo:
image: forgejo/forgejo:latest
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- forgejo_data:/data
environment:
- SECRET_KEY=your_secret_key_here
- DB_TYPE=sqlite3
volumes:
forgejo_data:
Replace your_secret_key_here with a secure string.
Step 5: Start Forgejo
Inside the /opt/forgejo directory, run:
docker-compose up -d
You can check if Forgejo is running with:
docker ps
Step 6: Access Forgejo
Once Forgejo is up and running, access it by navigating to http://<your-vps-ip>:3000 in your web browser. Follow the on-screen prompts to complete the setup.
Frequently Asked Questions (FAQs)
1. What features does Forgejo provide for developers?
Forgejo offers a variety of features that are crucial for developers, including repository management, issue tracking, pull requests, and code reviews. It supports various Git workflows and allows for collaboration among team members, making it an excellent choice for teams of any size. Additionally, the self-hosted nature provides a layer of security and privacy, allowing you to manage your codebase without relying on third-party platforms.
2. How secure is self-hosting Forgejo on Hetzner?
Self-hosting Forgejo on Hetzner can be secure if you follow best practices. This includes keeping your software updated, using SSH keys for access, and configuring firewalls to restrict unwanted access. Hetznerโs data centers are designed with physical security measures in place, and additional security can be implemented through Docker configurations and network settings. Regular backups and monitoring can further enhance your security posture.
3. Can I scale my VPS if my needs increase?
Yes, Hetzner provides the flexibility to scale your VPS as needed. If your Forgejo instance starts to receive more traffic or requires additional resources, you can easily upgrade your VPS to a plan with more CPU and RAM. This scalability ensures that you wonโt outgrow your hosting environment, and you can continue to self-host your applications seamlessly. Always monitor your resource usage to better predict when an upgrade may be necessary.
For a complete overview of VPS options suitable for your needs, visit our full VPS comparison.
Self-host Forgejo on Hetzner for a robust and secure development platform tailored to your personal or team projects. Happy coding!