---
title: "Deploy Forgejo — Self-Hosted GitHub Alternative & Git Forge"
description: "Self-host Forgejo: lightweight GitHub alternative with CI. No per-seat fees"
category: "Other"
url: https://railway.com/deploy/forgejo-git-forge
---

# Deploy Forgejo — Self-Hosted GitHub Alternative & Git Forge

Self-host Forgejo: lightweight GitHub alternative with CI. No per-seat fees

**[Deploy Forgejo — Self-Hosted GitHub Alternative & Git Forge on Railway](https://railway.com/template/forgejo-git-forge)**

- **Creator:** SilverBanana
- **Category:** Other

## Template content

### Forgejo https://forgejo.org/favicon.svg

- **Image:** mstreicherde/forgejo
- **Public domain:** Yes

## Documentation

# Deploy and Host Forgejo on Railway

Forgejo is the community-governed, self-hosted Git forge — a lightweight GitHub and GitLab
alternative in Go, backed by the non-profit Codeberg e.V. Everything you actually use GitHub for
in one binary: repositories, issues, pull requests with review, wikis, a package and container
registry, LFS, SSH/HTTP Git, and Forgejo Actions — CI/CD compatible with GitHub Actions YAML.
It's the self-hosting community's default recommendation in 2026, idling at ~170MB RAM vs GitLab's 8GB.

GitHub Enterprise Cloud runs $21/user/month — a 50-person team pays ~$12,600/year. A self-hosted
Forgejo instance handles the same team for the cost of compute. Self-host on Railway for
~$5–15/month with your code, issues, and CI on infrastructure you own, under GPL-v3 with no
per-seat pricing and no risk of a surprise license change.

---

## What This Template Deploys

| Service | Purpose |
|---|---|
| **Forgejo** | The Git forge — web UI, Git over HTTP/SSH, issues, PRs, packages, and Forgejo Actions, on port `3000` |
| **PostgreSQL** | Stores users, repositories metadata, issues, PRs, and settings |
| **Persistent Volume** | Mounted at `/var/lib/gitea` — your Git repositories, LFS objects, and avatars survive every redeploy |

Both services connect over Railway's private network with credentials injected automatically.
Forgejo is a single Go binary (frontend compiled in — no separate Node process), so it's light
and fast. Repositories live on the volume; metadata in PostgreSQL — the production-grade setup.

---

## About Hosting Forgejo

GitHub works until it doesn't — price hikes, Copilot training on your private code, telemetry, and
source that lives on infrastructure you don't control. Forgejo flips that: a forge you own, light
enough for a Raspberry Pi or a small Railway service. It forked from Gitea in 2022 over corporate
governance concerns and is now run by an elected council under a German non-profit.

Running it means the binary, a database, a volume for repos, and HTTPS with SSH for Git. Railway
wires the app and PostgreSQL over private networking with automatic HTTPS, and the volume keeps
your repositories safe across redeploys.

> **Note on federation:** Forgejo's ActivityPub federation is actively developed but still
> experimental as of 2026 — an opt-in roadmap feature, not a production default. Everything else
> (repos, PRs, CI, packages) is production-ready and used at scale on Codeberg.

Typical cost: **~$5–15/month** on Railway for Forgejo and PostgreSQL. GitHub Enterprise Cloud is
$21/user/month; GitLab SaaS Premium is $29/user/month. Self-hosted Forgejo has no per-seat fee —
flat compute regardless of team size, with full data ownership.

---

## Deploy in Under 5 Minutes

1. Click **Deploy on Railway** — Forgejo and PostgreSQL build automatically (~3–4 minutes)
2. Database credentials are wired automatically via Railway reference variables
3. Set `FORGEJO__server__ROOT_URL` to your Railway public domain (needed for correct links and clones)
4. Open your Railway URL and complete the first-run setup — the first registered user is admin
5. Create a repository, or import your existing repos from GitHub, GitLab, or Gitea with the migration tool

No reverse proxy setup. No manual database wiring. No SSL configuration.

---

## Common Use Cases

- **Self-hosted alternative to GitHub** — repos, issues, PRs, code review, and CI on your own
  infrastructure, with no per-seat bill and no code training a third party's AI
- **Lightweight alternative to GitLab** — the same core forge workflow at ~170MB RAM instead of
  GitLab's 8GB+, so it runs cheaply on a small instance
- **Escape Gitea's corporate direction** — Forgejo is the community-governed fork under a
  non-profit; choose it for FOSS governance and no surprise license changes
- **GitHub Actions-compatible CI/CD** — Forgejo Actions runs GitHub Actions YAML workflows on your
  own runners, so you migrate pipelines with minimal changes
- **Private package and container registry** — host npm, PyPI, Maven, Docker, and more from the
  same forge, keeping your artifacts alongside your code

---

## Configuration

| Variable | Required | Description |
|---|---|---|
| `FORGEJO__server__ROOT_URL` | ✅ Required | Your Railway public domain — used for clone URLs, links, and webhooks |
| `FORGEJO__database__DB_TYPE` | ✅ Pre-set | `postgres` — the database driver |
| `FORGEJO__database__HOST` | ✅ Auto-injected | PostgreSQL host via Railway reference variable |
| `FORGEJO__database__NAME` | ✅ Auto-injected | Database name |
| `FORGEJO__database__USER` | ✅ Auto-injected | Database user |
| `FORGEJO__database__PASSWD` | ✅ Auto-injected | Database password via Railway reference variable |
| `FORGEJO__server__SSH_DOMAIN` | Recommended | Domain for SSH Git access |
| `FORGEJO__security__INSTALL_LOCK` | Recommended | Set `true` after setup to lock the installer |
| `PORT` | Pre-set | `3000` — the web UI port |

> Set `FORGEJO__server__ROOT_URL` to your Railway domain, or clone URLs and links point to the
> wrong host. The first user to register becomes admin — register immediately and set
> `INSTALL_LOCK=true`. Forgejo uses `__` in env vars to map to `app.ini` sections.

---

## Forgejo vs. Git Platforms

| | Forgejo (Railway) | GitHub | GitLab CE | Gitea |
|---|---|---|---|---|
| **Monthly cost** | ~$5–15 flat | $21/user (Enterprise) | Self-host, 8GB+ RAM | Self-host |
| **Per-seat fees** | ✅ None | ❌ Yes | ✅ None | ✅ None |
| **RAM footprint** | ✅ ~170MB idle | N/A | ❌ 8GB+ | ✅ ~140MB |
| **Governance** | ✅ Non-profit council | ❌ Microsoft | ⚠️ Company (open core) | ⚠️ Company (Gitea Ltd) |
| **GitHub Actions-compatible CI** | ✅ Forgejo Actions | ✅ Native | ⚠️ Own CI | ✅ Gitea Actions |
| **Package/container registry** | ✅ Built-in | ✅ Yes | ✅ Yes | ✅ Built-in |
| **Import from GitHub/GitLab** | ✅ Yes | N/A | ✅ Yes | ✅ Yes |
| **License** | ✅ GPL-v3 | ❌ Proprietary | ⚠️ Open core | ⚠️ MIT (can go proprietary) |

---

## Dependencies for Forgejo Hosting

- Railway account — Hobby plan (~$5–15/month) for Forgejo and PostgreSQL
- A persistent volume mounted at `/var/lib/gitea` for repositories and LFS
- Optional: a Forgejo Actions runner for CI/CD, and an SMTP relay for email notifications

### Deployment Dependencies

- [Forgejo Source (Codeberg)](https://codeberg.org/forgejo/forgejo) — the project's home
- [Forgejo Documentation](https://forgejo.org/docs/) — setup, config, and admin guides
- [Forgejo Actions Docs](https://forgejo.org/docs/latest/user/actions/) — GitHub Actions-compatible CI

### Implementation Details

This template deploys the official Forgejo image with PostgreSQL over Railway's private network and
a persistent volume at `/var/lib/gitea` for repositories, LFS objects, and avatars. Forgejo is a
single Go binary with the Vue.js frontend compiled in — no separate Node process — which is why it
idles around 170MB.

Config uses the `FORGEJO__section__KEY` env-var pattern mapping to `app.ini`. Set `ROOT_URL` to
your Railway domain so clone URLs and webhooks resolve, and lock the installer with
`INSTALL_LOCK=true` after setup. Repositories persist on the volume, metadata in PostgreSQL. For
CI, register a Forgejo Actions runner to execute GitHub Actions-compatible YAML workflows.

---

## Frequently Asked Questions

**How much does Forgejo save versus GitHub or GitLab?**
GitHub Enterprise Cloud is $21/user/month — $12,600/year for 50 people. GitLab Premium is
$29/user/month. Self-hosted Forgejo on Railway is ~$5–15/month flat regardless of team size — it
pays for itself in the first month for any real team, with no per-seat pricing.

**What's the difference between Forgejo and Gitea?**
Forgejo forked from Gitea in 2022 after a for-profit company took over Gitea's governance. They
share most of their codebase and remain highly compatible, but Forgejo is governed by an elected
council under the non-profit Codeberg e.V., is GPL-v3 (so it can't go proprietary), patches
security faster, and leads on federation. For new self-hosted installs in 2026, Forgejo is the
community default.

**Can I import my repositories from GitHub?**
Yes. Forgejo's built-in migration tool imports repositories from GitHub, GitLab, Gitea, and
Bitbucket, including issues and pull requests in many cases. Point it at the source repo with a
token and it pulls everything over.

**Does it have CI/CD like GitHub Actions?**
Yes — Forgejo Actions runs workflows using GitHub Actions-compatible YAML syntax, so most existing
Actions workflows port with minimal changes. Register a Forgejo Actions runner (on Railway or an
external host) to execute jobs.

**Do I lose my repositories if Railway redeploys?**
No. Git repositories, LFS objects, and avatars live on the persistent volume at `/var/lib/gitea`,
and metadata in PostgreSQL. Redeploys and updates don't affect your data. As always, keep
independent backups of anything critical.

**Is Forgejo's federation ready to use?**
Federation (ActivityPub forge-to-forge interaction) is actively developed but still experimental as
of 2026 — treat it as an opt-in roadmap feature, not a production default. The core forge (repos,
PRs, CI, packages) is fully production-ready and runs Codeberg, one of the largest public instances.

---

## Why Deploy and Host Forgejo on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your
infrastructure so you don't have to deal with configuration, while allowing you to vertically and
horizontally scale it.

By deploying Forgejo on Railway, you get a lightweight, community-governed Git forge — repos, PRs,
CI via Forgejo Actions, and a package registry — backed by PostgreSQL and persistent storage at
~$5–15/month flat, with no per-seat fees and full ownership of your code.

## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — [Jul'26] Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/forgejo-git-forge
