---
title: "Deploy Forgejo"
description: "Self-host Forgejo, a lightweight Git forge, with CI, Postgres and Redis"
category: "Other"
url: https://railway.com/deploy/forgejo-railway
---

# Deploy Forgejo

Self-host Forgejo, a lightweight Git forge, with CI, Postgres and Redis

**[Deploy Forgejo on Railway](https://railway.com/template/forgejo-railway)**

- **Creator:** A3A
- **Category:** Other
- **Total deploys:** 1

## Template content

### forgejo https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/forgejo.svg

- **Source:** https://github.com/gridalpha/forgejo-railway
- **Public domain:** Yes

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### forgejo-runner https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/forgejo.svg

- **Source:** https://github.com/gridalpha/forgejo-railway

### Redis https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg

- **Image:** redis:8.2
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

## Buckets

- **forgejo-storage**

## Documentation

![Forgejo logo](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTkoiMufeAuOKRRJ6vSLWjQiiTkvjfBpfe5PTL6djOdNQ&amp;s)

# Deploy and Host Forgejo on Railway

Forgejo is a lightweight, community-governed Git forge: repositories, pull requests, issues, releases, a package registry and built-in CI, all from a single Go binary. It began in 2022 as a fork of Gitea led by the people behind Codeberg, is published under the GPL-3.0-or-later licence with no paid edition, and has become the default choice for teams who want GitHub's workflow without GitHub's ownership of their code. Small teams, universities and open-source projects self-host Forgejo for private repositories, auditable access control and CI they control.

This template lets you deploy Forgejo on Railway with the parts a real forge needs already wired together: the Forgejo web and SSH service, a **Forgejo Actions runner** so CI actually executes, **PostgreSQL** for metadata, **Redis** for cache, sessions and queues, a **storage bucket** for attachments, LFS objects, packages and CI logs, and a **volume** for the Git repositories. Browser traffic arrives over HTTPS on the public domain, `git push` over HTTPS or over SSH through a TCP proxy, and the runner reaches Forgejo over Railway's private network. The first administrator account is created before the web server accepts its first request, so the instance is never reachable without an owner.

![Forgejo Railway architecture](https://res.cloudinary.com/rroe4rtk/image/upload/v1786825558/588a9ec6-7d2c-4d79-883f-5c1e83ce4b19.png)

## Getting Started with Forgejo on Railway

Open the public URL once the deployment is green and you will land on a working forge with registration already closed. Sign in with the administrator username and password you set at deploy time — there is no setup wizard and no default password to change, because the account is created during the first boot. Create your first repository from the **+** menu, tick *Initialize repository*, and clone it over HTTPS using the URL on the repository page. For SSH, add a public key under *Settings → SSH / GPG keys* and clone from the address on the SSH tab, which already carries the proxy host and port. To confirm CI is alive, commit a workflow at `.forgejo/workflows/ci.yml` with `runs-on: host` and push: the run appears under the repository's **Actions** tab within seconds. The bundled runner shows as idle under *Site Administration → Actions → Runners*, and you can invite your team from *Site Administration → User Accounts*.

![Forgejo repository page showing files and rendered README](https://res.cloudinary.com/rroe4rtk/image/upload/v1786815719/forgejo-repository-home.png)
![Forgejo Actions run with passing job steps and output](https://res.cloudinary.com/rroe4rtk/image/upload/v1786815720/forgejo-actions-run.png)
![Forgejo issue thread with a CSV file attached](https://res.cloudinary.com/rroe4rtk/image/upload/v1786815725/forgejo-issue-attachment.png)

## About Hosting Forgejo

Forgejo does what a Git host has to do and stops there: it serves repositories, reviews code and runs CI, without the sprawl that makes larger platforms expensive to operate. Self-host it when code must stay on infrastructure you control, or when per-seat pricing stops making sense.

- Repositories with pull requests, code review, protected branches and required checks
- Issues, labels, milestones, projects and a per-repository wiki
- Forgejo Actions, a CI system whose workflow syntax is compatible with GitHub Actions
- A package registry covering container images, npm, Maven, PyPI, Cargo, NuGet and more
- Git LFS, mirroring, releases, a REST API, organisations, teams and two-factor authentication

The forge runs as one service because Git repositories live on a filesystem, and the volume at `/data` makes them durable across restarts. PostgreSQL holds every row that is not a Git object: users, issues, pull requests, CI runs. Redis carries the cache, sessions and queues, so a redeploy does not sign everyone out.

## Why Deploy Forgejo on Railway

Railway removes the operational work that usually comes with running a forge.

- PostgreSQL, Redis and object storage are provisioned and connected for you
- The public HTTPS domain and its certificate are issued automatically
- A TCP proxy exposes Git over SSH without running your own server
- The Actions runner is registered at deploy time, so CI works immediately
- Volumes, health checks and restart policies are configured already

## Common Use Cases

- A private forge for a team that wants GitHub's workflow on its own infrastructure
- Client or contract work whose source cannot sit on a third-party platform
- Mirroring public repositories to keep a durable, self-owned copy with its own CI
- Publishing internal container images, npm packages or Python wheels

## Dependencies for Forgejo

- **Forgejo** — `codeberg.org/forgejo/forgejo:16`: web UI, Git HTTP, SSH and API
- **Forgejo Actions runner** — `code.forgejo.org/forgejo/runner:13`, runs CI workflows
- **PostgreSQL 18** — repository metadata, issues, pull requests, CI history
- **Redis** — cache, session store and background queues
- **Storage bucket** — attachments, avatars, LFS, packages, release assets, job logs
- **Volume at `/data`** — Git repositories and SSH host keys

### Environment Variables Reference

| Variable | Purpose |
|---|---|
| `FORGEJO_ADMIN_USERNAME` / `_PASSWORD` / `_EMAIL` | The first administrator account |
| `FORGEJO_RUNNER_SECRET` | Shared secret linking the runner to the forge |
| `FORGEJO_RUNNER_LABELS` | Labels a workflow's `runs-on` must match |
| `FORGEJO_RUNNER_CAPACITY` | Concurrent CI jobs per runner |
| `FORGEJO__service__DISABLE_REGISTRATION` | Set `false` to allow public signup |
| `FORGEJO__mailer__ENABLED` | Set `true` and add SMTP settings to send notifications |

Any setting in Forgejo's `app.ini` can be supplied as `FORGEJO__<section>__`; a dot inside a section name is escaped as `_0X2E_`.

### Deployment Dependencies

- Source: [codeberg.org/forgejo/forgejo](https://codeberg.org/forgejo/forgejo) and [code.forgejo.org/forgejo/runner](https://code.forgejo.org/forgejo/runner)
- Documentation: [forgejo.org/docs](https://forgejo.org/docs/latest/)

## Hardware Requirements for Self-Hosting Forgejo

| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU | 2 vCPU, plus 2 for the runner |
| RAM | 512 MB | 2 GB, plus 2 GB for the runner |
| Storage | 5 GB volume | 20 GB+, sized to your repositories |
| Runtime | Go binary, Linux container | PostgreSQL 18, Redis, S3-compatible storage |

Forgejo is frugal — the binary idles in a few hundred megabytes. CI consumes the resources, so give the runner headroom matching the builds you expect.

## Self-Hosting Forgejo with Docker

The template needs none of this, but it is what running Forgejo yourself looks like. Start the forge with SQLite and a local volume:

```
docker run -d --name forgejo \
  -p 3000:3000 -p 222:22 \
  -v forgejo-data:/data \
  codeberg.org/forgejo/forgejo:16
```

Point it at PostgreSQL with environment variables instead of editing `app.ini` by hand:

```
docker run -d --name forgejo \
  -e FORGEJO__database__DB_TYPE=postgres \
  -e FORGEJO__database__HOST=postgres:5432 \
  -e FORGEJO__database__NAME=forgejo \
  -e FORGEJO__database__USER=forgejo \
  -e FORGEJO__database__PASSWD=changeme \
  -v forgejo-data:/data codeberg.org/forgejo/forgejo:16
```

## How Much Does Forgejo Cost to Self-Host?

Forgejo is free software under the GPL-3.0-or-later licence: no paid tier, no enterprise edition, no per-seat pricing, every feature including CI and the package registry available to everyone. Self-hosting costs only infrastructure, so on Railway you pay for the compute, storage and bandwidth the forge and its runner use. CI usually moves the bill.

## Forgejo vs Gitea vs GitLab CE

| | Forgejo | Gitea | GitLab CE |
|---|---|---|---|
| Governance | Non-profit, elected | For-profit company | Public company |
| Licence | GPL-3.0-or-later | MIT, open-core add-ons | MIT, paid tiers |
| Footprint | Go binary, ~512 MB | Go binary, ~512 MB | 4 GB+, several services |
| CI | Forgejo Actions | Gitea Actions | GitLab CI |

Forgejo and Gitea feel almost identical to use; the difference is who decides where the project goes. GitLab CE is heavier, worth it for a whole DevOps suite rather than a Git forge.

## FAQ

**What is Forgejo?**

A self-hosted Git forge for hosting repositories, reviewing pull requests, tracking issues and running CI, maintained by a non-profit under the GPL-3.0-or-later licence.

**What does this Railway template deploy?**

Forgejo, a Forgejo Actions runner, PostgreSQL, Redis and a storage bucket, plus a volume for Git repositories, a public HTTPS domain and a TCP proxy for Git over SSH.

**Why does the template include PostgreSQL, Redis and a storage bucket?**

Forgejo can run on SQLite and local disk, but that does not survive a container being replaced. PostgreSQL holds the metadata, Redis keeps sessions and queues out of process memory, and the bucket stores attachments, LFS objects and packages without filling the volume.

**How do I run CI on self-hosted Forgejo?**

The runner ships registered and idle. Commit a workflow to `.forgejo/workflows/` with `runs-on: host` and push. Syntax is largely GitHub Actions compatible, so many workflows run with only the `runs-on` line changed.

**How do I add users if registration is disabled?**

Create them from *Site Administration → User Accounts*, or set `FORGEJO__service__DISABLE_REGISTRATION` to `false` to reopen signup.

**Is CI isolated from the forge?**

The runner executes jobs in its own container, separate from Forgejo, but workflow steps are not sandboxed from that container. Give push access only to people you trust with it.
</section>

## 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-railway
