Deployment guide

Host Gitea on your own VPS in 2026

Deploy on a VPS Cloud →

Tutorial

Host Gitea on your own VPS in 2026

Self-hosting11 min read12 steps

Gitea is a self-hosted Git forge written in Go, renowned for being lightweight and fast. Deploying it on your own VPS gives you a private GitHub with no per-user subscription and no limit on private repositories. In 2026, Gitea 1.25 is the current version and Forgejo v16 has established itself as the reference community fork — this guide covers Gitea installation, setting up CI/CD pipelines with Gitea Actions, the comparison with Forgejo, daily administration, and troubleshooting the most common errors.

Contents· Why self-host Gitea on a VPS1/13
  1. 01Why self-host Gitea on a VPS
  2. 02Concrete benefits of a self-hosted Gitea
  3. 03Hardware and software prerequisites
  4. 04Deploy Gitea with Docker and SSL
  5. 05Gitea Actions: self-hosted CI/CD on your VPS
  6. 06Gitea or Forgejo in 2026: which one to choose?
  7. 07Migrate from Gitea to Forgejo
  8. 08Forgejo v16: key highlights (July 2026)
  9. 09Daily administration: webhooks, repositories and orphan cleanup
  10. 10Advanced troubleshooting: SSH and HTTPS cloning
  11. 11Upgrading to Gitea 1.27 without losing SSH access
  12. 12Going further: Forgejo and advanced CI/CD
  13. 13The official documentation

Why self-host Gitea on a VPS

Gitea uses barely 200 to 300 MB of RAM at idle, making it one of the most efficient Git forges to self-host. On a VPS, you keep full control of your source code: no data is analyzed by a third party, no arbitrary limit on the number of private repositories or collaborators, and no cost that climbs with your team. For an agency or an independent developer, a single VPS can host all client projects with permissions partitioned by organization. Gitea natively includes CI/CD compatible with GitHub Actions workflows (Gitea Actions), a package registry and a web editor, which covers almost the entire development cycle with no external dependency.

Concrete benefits of a self-hosted Gitea

  • Minimal memory footprint: runs comfortably on a 2 GB RAM VPS even with several dozen users.
  • Private repositories without per-seat billing or imposed limits, unlike SaaS offerings.
  • Gitea Actions built in to run your CI/CD pipelines without an external service.
  • Package registry (Docker, npm, Composer, Maven) hosted on the same instance.
  • Fine-grained authentication: LDAP, OAuth2, personal access tokens and per-user SSH keys.
  • Trivial backup: everything fits in one data volume and a database.

Hardware and software prerequisites

Gitea is very frugal. For a small team (up to 20 users), a VPS with 2 vCPU and 2 GB of RAM is more than enough; count on 4 GB if you enable Gitea Actions with local runners that compile code. Plan for at least 20 to 40 GB of SSD storage depending on the size of your repositories. On the software side: Docker Engine and the Docker Compose plugin installed, a domain name (or a subdomain such as git.yourdomain.com) pointing to the VPS IP via an A record, and port 22 reserved for the server's SSH — Gitea will expose its own SSH on another port to avoid the conflict.

Deploy Gitea with Docker and SSL

  1. Prepare the VPS and Docker

    Connect via SSH, update the system then install Docker and the Compose plugin. Create a dedicated directory: mkdir -p /opt/gitea && cd /opt/gitea. Also create a data volume that will survive container updates.

  2. Write the docker-compose.yml

    Define two services: gitea (image gitea/gitea:1.25) and a postgres:16 database. Mount ./gitea:/data for persistence, set USER_UID/USER_GID to 1000, and map Gitea's SSH to host port 2222: "2222:22". Leave the HTTP port 3000 internal; it will be served by the reverse proxy.

  3. Launch the containers

    Run docker compose up -d then docker compose logs -f gitea to follow the initialization. Check that the connection to PostgreSQL succeeds before continuing.

  4. Configure the reverse proxy

    With Caddy, a single line is enough: git.yourdomain.com { reverse_proxy localhost:3000 }. Caddy automatically obtains and renews the Let's Encrypt certificate. With Nginx, create a server that proxies to http://127.0.0.1:3000 and use certbot --nginx for SSL.

  5. Finalize the web installation

    Open https://git.yourdomain.com, complete the wizard by filling in the HTTPS base URL and the database host (db:5432). Set ROOT_URL correctly, otherwise the clone links will be wrong. Expand "Optional Settings > Administrator Account Settings", create your admin account there, then submit.

  6. Secure repository SSH

    Configure your clients to clone via ssh://[email protected]:2222/..., or add a Host block in ~/.ssh/config to hide the port. Disable public sign-up in the admin if the instance is private.

Gitea Actions: self-hosted CI/CD on your VPS

Gitea Actions is Gitea's native CI/CD engine, compatible with GitHub Actions workflow syntax. It lets you run pipelines directly on your infrastructure, with no dependency on an external service.

To enable it, add to your app.ini:

[actions]
ENABLED = true

Then register an act_runner runner in a separate container on the same VPS. Cap its RAM via mem_limit so that a heavy build does not choke Gitea itself. For heavy pipelines (compilation, integration tests), dedicate a second VPS to the runner instead.

A minimal workflow for a Node.js project goes in .gitea/workflows/ci.yml:

on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '22'
      - run: npm ci
      - run: npm test

The runner executes this workflow on every push. You can combine multiple jobs, use version matrices, and share artifacts between steps — exactly like GitHub Actions, but on your own server.

Cap the act_runner container RAM to 2 GB via mem_limit: 2g in your docker-compose.yml if your VPS has 4 GB total. That way, even a build that consumes everything allocated to it still leaves 2 GB for Gitea — enough to keep serving pushes and pull requests during compilation. For builds that produce large artifacts (Docker images, binaries), add a separate volume mounted at /home/runner/work to avoid filling Gitea's main data volume.

Gitea or Forgejo in 2026: which one to choose?

Scroll the table

CriterionGitea 1.25Forgejo v16
GovernanceCommercial company (Gitea Ltd)Non-profit association (Codeberg e.V.)
LicenseMITMIT — 100% free software, no enterprise edition
Recommended by Awesome-SelfhostedNo (removed in 2022)Yes — default recommendation since 2024
ActivityPub federationNot plannedRolling out since Forgejo v7 (April 2024), GA in v16
Gitea API compatibilityReferenceCompatible: same API, same webhooks, same data format
Security — public auditsRareCode audits published by the Codeberg community
Community roadmapDriven by Gitea LtdOpen governance, public RFCs, contributor voting
Migration from GiteaN/ANo data loss: same database schema and same volume format

Migrate from Gitea to Forgejo

  1. Back up your Gitea instance

    Before anything, create a full dump: docker exec -u git gitea gitea admin dump -c /data/gitea/conf/app.ini. Retrieve the generated archive outside the container and verify that the ./gitea volume is included in your VPS snapshot.

  2. Check version compatibility

    Forgejo v16 supports migration from Gitea 1.20 and later. If your instance is running an older version, first upgrade to Gitea 1.21 or 1.22 via docker compose pull && docker compose up -d, then verify there are no errors in the logs before proceeding.

  3. Replace the Docker image

    In your docker-compose.yml, replace image: gitea/gitea:latest with image: codeberg.org/forgejo/forgejo:latest. The data volume (./gitea:/data) and the PostgreSQL database remain unchanged — Forgejo reads the same schema and the same app.ini.

  4. Restart and let it migrate

    Run docker compose pull && docker compose up -d. Forgejo automatically applies the necessary schema migrations at startup. Follow docker compose logs -f forgejo until the message indicating that the HTTP server is listening on port 3000.

  5. Regenerate SSH keys

    As with any upgrade that changes the binary referenced in authorized_keys, regenerate the entries: docker exec -u git forgejo forgejo admin regenerate keys. Then verify that a git clone over SSH succeeds from a client machine.

  6. Test and validate

    Open the web interface, check repositories, webhooks, and Forgejo Actions runners. act_runner runners registered under Gitea are compatible — reconnect them to the new registration token if the key has changed.

Forgejo v16: key highlights (July 2026)

Forgejo v16.0.0 brings ActivityPub federation to general availability for issues and pull requests: an issue opened on one Forgejo instance can receive comments from users on another instance, without a shared account. The release also includes an instance-level secrets manager (AES-256 encryption at rest), a new code search engine based on the Bleve v2 index with regex support, and significant improvements to the background task scheduler. On the security front, API tokens are now hashed in the database (bcrypt) instead of stored in plaintext — an automatic migration at startup converts existing tokens.

Daily administration: webhooks, repositories and orphan cleanup

Once Gitea is in production, a few maintenance operations come up regularly.

Managing webhooks. Gitea logs the history of every delivery in "Repository Settings → Webhooks → Recent Deliveries". A failed webhook (timeout, HTTP 5xx error) can be replayed manually from that history. If your runners run on the same private network as Gitea, add their IP ranges to ALLOWED_HOST_LIST in the [webhook] section of app.ini — otherwise calls to localhost are blocked by default since Gitea 1.20.

Purging orphaned repositories. A repository deleted through the interface leaves its Git data (objects/) on disk until the next background task run. Force an immediate pass from the admin: "Site Administration → Background Tasks → Run: Purge Deleted Repositories". The freed space only becomes visible after docker exec -u git gitea gitea admin storage --remove-unlisted.

Storage quota per organization. For multi-tenant instances, set a repository quota per organization in app.ini under [repository]: MAX_CREATION_LIMIT = 50. This prevents an account from creating hundreds of repositories unmonitored and filling the data volume.

Advanced troubleshooting: SSH and HTTPS cloning

Permission denied (publickey) after an upgrade. The binary referenced in authorized_keys has changed path (verified in 1.27). The Gitea service responds normally over HTTPS, which masks the problem. Fix with: docker exec -u git gitea gitea admin regenerate keys. Verify that a git clone over SSH succeeds before declaring the upgrade complete.

Timeout or SSL error during HTTPS clone. Three common causes: the ROOT_URL in app.ini does not match the actual HTTPS domain (broken links + possible redirect loop), the reverse proxy does not forward the X-Forwarded-Proto: https header (Gitea then generates HTTP URLs), or the Let's Encrypt certificate has expired (Caddy and certbot renew it automatically, but only if DNS still points to the VPS). Check ROOT_URL first: it is the most common cause after a domain migration.

Slow or stalling SSH clone. The SSH upload-pack uses the same Git process as web operations. If your act_runner is using all available CPU cores during a build, Git operations may end up waiting for CPU. Add cpus: '1.5' to the runner in the compose to reserve cores without starving it completely.

Database migration failed: column already exists. The database received a partial migration (stopped mid-upgrade). Restore the dump taken before the upgrade, start from a clean volume, then restart.

Upgrading to Gitea 1.27 without losing SSH access

Version 1.27 changes the internal path of the gitea binary referenced inside authorized_keys. During the upgrade, existing entries still point to the old path: any clone or push over SSH silently fails with Permission denied (publickey), without any server-side error message pointing to the upgrade. The Gitea service responds normally over HTTPS, which masks the problem. After every upgrade to 1.27 (or to any version that changes this path), run inside the container: docker exec -u git gitea gitea admin regenerate keys. The command rewrites all authorized_keys entries with the correct binary path. Verify that a git clone over SSH succeeds before declaring the upgrade complete.

JWT_SECRET_URI and JWT_SECRET must not coexist in app.ini. If both keys are present, Gitea or Forgejo loads one or the other depending on read order, silently invalidating all OAuth2 and Actions tokens issued before the upgrade. Users see intermittent authentication errors with no message pointing to app.ini as the cause. Choose one mechanism: JWT_SECRET (plaintext value) or JWT_SECRET_URI (path to a secret file), then remove the other. Restart the container after the change.

Going further: Forgejo and advanced CI/CD

If you want to push automation around your Git forge further, the article Host Forgejo on your VPS covers setting up a Forgejo instance with dedicated Actions runners, configuring the built-in OCI registry, and security hardening (fail2ban, IP range restrictions). For teams wanting a complete continuous deployment pipeline, it is the natural complement to this guide.

The official documentation

For advanced configuration and options specific to the tool, refer to the official Gitea documentation or the Forgejo documentation. This guide covers going live on a VPS and migration; the vendor docs remain the reference for fine-tuning and specific use cases.

Deploy Gitea or Forgejo in minutes on a ServOrbit Cloud VPS

Our Cloud VPS, delivered with Docker preconfigured, lets you set up your Git forge with automatic SSL, without system tinkering. Dedicated resources, snapshots and a fixed IP included.

Need help?

Browse our help center and FAQ, or reach our team — callback, WhatsApp or email. Support in French, English and Arabic.

Message us on WhatsAppopens in a new tab