Independent testing Updated April 2026 387 self-hosting guides 5 VPS providers tested

guide

How to Self-Host Forgejo on a VPS (Complete Guide)

A complete step-by-step guide to self-hosting Forgejo on a VPS in 2026, covering installation, configuration, securing Forgejo, and the specs you need.

How to Self-Host Forgejo on a VPS (Complete Guide)

Forgejo is a powerful, open-source self-hosted Git service that provides a seamless experience for managing your projects and repositories. Deploying it on a Virtual Private Server (VPS) allows you to maintain full control over your data and customize your environment. This guide walks you through the steps required to self-host Forgejo on a VPS, covering everything from installation to configuration.

Prerequisites

Before you begin, make sure you have the following:

Choosing a VPS Provider

When selecting a VPS provider, consider factors like performance, price, and support. Below is a comparison of some top VPS providers suitable for hosting Forgejo:

ProviderPrice (per month)RAMStorageData Centers
Contabo VPS5.99 EUR4 GB200 GBEurope
Hetzner Cloud4.15 EUR2 GB20 GBEurope
DigitalOcean6 USD1 GB25 GBGlobal
Vultr6 USD1 GB25 GBGlobal
Linode (Akamai Cloud)5 USD1 GB25 GBGlobal

All prices are competitive and provide a solid foundation for self-hosting applications like Forgejo. Check out our full VPS comparison for more options.

Step 1: Setting Up Your VPS

  1. Access Your VPS: Use SSH to log in to your VPS.

    ssh root@your_server_ip
  2. Update the System: Ensure your VPS is up to date.

    apt update && apt upgrade -y
  3. Install Docker and Docker Compose:

    apt install docker.io docker-compose -y
  4. Start Docker Service:

    systemctl start docker
    systemctl enable docker

Step 2: Deploying Forgejo with Docker

  1. Create a Directory for Forgejo:

    mkdir -p /opt/forgejo
    cd /opt/forgejo
  2. Create the docker-compose.yml File:

    Use your preferred text editor to create the file.

    nano docker-compose.yml

    Add the following content:

    version: '3'
    
    services:
      forgejo:
        image: forgejo/forgejo:latest
        environment:
          - GITEA__database__DB_TYPE=sqlite3
          - GITEA__database__PATH=/data/gitea/gitea.db
          - GITEA__server__DOMAIN=yourdomain.com
          - GITEA__server__ROOT_URL=https://yourdomain.com
        volumes:
          - ./data:/data
        ports:
          - "3000:3000"
          - "22:22"
        restart: unless-stopped

    Adjust the DOMAIN and ROOT_URL to your actual domain name.

  3. Start Forgejo:

    docker-compose up -d

Step 3: Accessing Forgejo

After the container starts, you can access Forgejo by navigating to http://yourdomain.com:3000 in your web browser. Complete the initial setup, including admin account creation.

Optional: Setting Up Reverse Proxy

For better security and SSL support, itโ€™s recommended to set up a reverse proxy. You can use NGINX or Traefik for this purpose. Below is a simple NGINX configuration example:

  1. Install NGINX:

    apt install nginx -y
  2. Create NGINX Configuration:

    nano /etc/nginx/sites-available/forgejo

    Add the following:

    server {
        listen 80;
        server_name yourdomain.com;
    
        location / {
            proxy_pass http://localhost: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;
        }
    }
  3. Enable Configuration:

    ln -s /etc/nginx/sites-available/forgejo /etc/nginx/sites-enabled/
    nginx -t
    systemctl restart nginx

FAQs

1. How secure is self-hosting Forgejo on a VPS?

Self-hosting Forgejo on a VPS can be secure, provided you follow best practices such as regularly updating your software, using strong passwords, and setting up firewalls. Ensure that your VPS provider offers DDoS protection and choose a data center location that suits your latency and security needs. Additionally, secure your Forgejo instance with HTTPS to encrypt data in transit. Check the security practices outlined in forums like r/selfhosted for more detailed recommendations.

2. Can I customize Forgejo features?

Yes, Forgejo is highly customizable. You can modify its settings via the administration panel to tailor it to your needs. Forgejo supports various authentication methods, repository permissions, and much more. Explore the official Forgejo documentation for comprehensive customization instructions and learn how to integrate it with CI/CD tools for enhanced productivity.

3. What if I encounter issues during installation?

If you face issues during the installation or configuration of Forgejo, consider searching through community forums such as r/selfhosted and GitHub issues. Additionally, ensure that Docker and Docker Compose versions are up to date as compatibility can sometimes cause issues. The Forgejo GitHub repository also contains valuable information and user support, making it a useful resource for troubleshooting.

By following this guide, you should now have a fully functional Forgejo instance running on your VPS. Happy coding and self-hosting!