
Git hosting looks easy until you need predictable access control, fast clones, and backups you can actually restore. At that point, “we’ll just keep it on GitHub” stops being a convenience choice and becomes an operational risk. If you want GitHub-style repos on infrastructure you control, you can run Forgejo on a VPS and keep the workflow familiar without GitLab-sized overhead.
This is an open-source spotlight. You’ll get the reasons and trade-offs first. Then you’ll get a deployment pattern you can operate: Docker Compose, SSH + HTTPS, TLS, backups, and a sane upgrade process.
Why you’d run Forgejo instead of “just using GitHub”
Forgejo is a self-hosted Git service for teams that want pull requests, code review, issues, and the basics. You get those features without handing repositories to a third party.
It’s a community-led fork of Gitea and ships under the MIT License. That keeps adoption and redistribution simple for companies.
Forgejo is a strong fit if any of these sound like your situation:
- You ship client work and need repository isolation with auditable access controls.
- You run internal services and want fast LAN clones with no reliance on public SaaS uptime.
- You have compliance requirements around data residency or where source code can live.
- You want predictable costs: one VPS, one bill.
Where Forgejo isn’t the best match: if you need an all-in-one enterprise suite (deep built-in CI, container registry, portfolio planning, compliance dashboards), GitLab may still be the better tool.
A lot of teams don’t need that. They need a dependable Git server with backups they trust.
Run Forgejo on a VPS: what you get vs GitHub and GitLab
Self-hosting is always a trade. These are the differences that show up in day-to-day operations.
- Versus GitHub (hosted): you swap “no ops work” for control. You set auth policies, retention, and network access. You also own patching and backups.
- Versus GitLab (self-managed): Forgejo is lighter on CPU/RAM, simpler to run, and easier to back up. GitLab can replace more tools, but it’s heavier and upgrades tend to need more planning.
- Versus Gitea: Forgejo targets the same product space, but its governance and community direction are a common deciding factor for teams in 2026.
If your goal is “private GitHub-like repos with sane ops,” Forgejo usually hits the sweet spot.
Infrastructure planning: sizing, storage, and networking
Forgejo is mostly I/O-bound for active teams. Repos, LFS objects, and the database all lean on disk. Don’t cheap out on storage performance.
- Small team (1–10 devs): 1–2 vCPU, 2–4 GB RAM, NVMe storage. Works well for dozens to hundreds of repos.
- Growing team (10–50 devs): 2–4 vCPU, 4–8 GB RAM, NVMe storage, and consider moving the database to a managed service or dedicated instance.
- Repo-heavy org: prioritize disk and backups. LFS and CI artifacts (if you add them later) can balloon storage quickly.
On the network side, you’ll usually expose:
- TCP 80/443 for HTTPS (web UI + Git over HTTPS)
- TCP 22 for SSH Git operations (or a custom port if you want to reduce noise)
If you want a clean, predictable base for Forgejo plus future services, a VPS is a sensible starting point. For production, consider a HostMyCode VPS with NVMe-backed storage so clones and fetches don’t bog down under load.
Deployment approach: Docker Compose with a real database
Forgejo can run on SQLite, but most operators outgrow it once backups, concurrency, and consistency matter. In practice, Postgres or MariaDB is the steady choice.
The example below uses Postgres. It’s predictable. You can back it up with one command.
Create directories:
sudo mkdir -p /opt/forgejo/{data,db,backup}
sudo chown -R root:root /opt/forgejo
Create /opt/forgejo/docker-compose.yml:
services:
db:
image: postgres:16-alpine
container_name: forgejo-db
environment:
POSTGRES_DB: forgejo
POSTGRES_USER: forgejo
POSTGRES_PASSWORD: change-this-password
volumes:
- ./db:/var/lib/postgresql/data
restart: unless-stopped
forgejo:
image: codeberg.org/forgejo/forgejo:latest
container_name: forgejo
depends_on:
- db
environment:
USER_UID: "1000"
USER_GID: "1000"
FORGEJO__database__DB_TYPE: postgres
FORGEJO__database__HOST: db:5432
FORGEJO__database__NAME: forgejo
FORGEJO__database__USER: forgejo
FORGEJO__database__PASSWD: change-this-password
# You will set ROOT_URL after you have a domain and TLS in place.
volumes:
- ./data:/data
ports:
- "127.0.0.1:3000:3000" # web UI behind reverse proxy
- "2222:22" # SSH for Git (host port 2222)
restart: unless-stopped
Bring it up:
cd /opt/forgejo
sudo docker compose up -d
sudo docker compose ps
Two details save headaches later:
- Mapping container SSH (22) to host port 2222 avoids clashing with your server’s own SSH daemon. You’ll tell users to clone with
ssh://git@yourdomain:2222/owner/repo.git. - Binding the web UI to
127.0.0.1keeps it off the public interface. Your reverse proxy will handle TLS and headers.
If you’re building a longer-term footprint (Git + monitoring + private registry), a managed VPS hosting plan can make sense. You keep root-level flexibility while someone else handles routine platform maintenance.
Reverse proxy + HTTPS: Nginx with Let’s Encrypt
Forgejo behaves well behind Nginx. You mainly need two things: ROOT_URL and the forwarded headers. When those are correct, Forgejo generates the right links and clone URLs.
Assumptions:
- You own a domain (or subdomain) like
git.example.com - DNS A/AAAA records point to your VPS IP
If you need a DNS refresher, HostMyCode’s domain service keeps it straightforward: Domains at HostMyCode.
Install Nginx and Certbot on Ubuntu/Debian:
sudo apt update
sudo apt install -y nginx certbot python3-certbot-nginx
Create /etc/nginx/sites-available/forgejo:
server {
listen 80;
server_name git.example.com;
location /.well-known/acme-challenge/ {
root /var/www/html;
}
location / {
proxy_pass http://127.0.0.1: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;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
}
Enable and test:
sudo ln -s /etc/nginx/sites-available/forgejo /etc/nginx/sites-enabled/forgejo
sudo nginx -t
sudo systemctl reload nginx
Issue a certificate:
sudo certbot --nginx -d git.example.com
Now set Forgejo’s external URL so the UI shows the right hostname in links and clone commands. You can do this in the web admin UI. You can also set an env var.
The env-var approach is explicit and easy to track in Git:
# /opt/forgejo/docker-compose.yml (forgejo service)
# Add:
# FORGEJO__server__ROOT_URL: https://git.example.com/
Apply the change:
cd /opt/forgejo
sudo docker compose up -d
If you want to standardize your reverse-proxy setup across apps (Forgejo today, something else later), the Nginx pattern in Deploy Gitea on a VPS With SSH Git and HTTPS is a useful reference. The moving parts are almost identical.
SSH Git access: make it predictable for developers
Developers usually ask two things: “What’s the clone URL?” and “Which SSH key do I add?” Keep those answers stable, and your support load drops fast.
- If you kept the container SSH mapping as
2222:22, cloning looks like:
git clone ssh://git@git.example.com:2222/your-org/your-repo.git
Two common pitfalls to avoid:
- Firewall: open your chosen SSH Git port (2222 in this example) and 80/443. On Ubuntu with UFW:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 2222/tcp
sudo ufw status
- Host SSH confusion: keep server admin SSH on port 22. Keep Git SSH on 2222. Mixing them tends to create messy access rules later.
If you’re hardening the VPS, UFW plus Fail2ban is still a solid baseline in 2026. This tutorial pairs well with the Nginx setup: Set Up Fail2ban for Nginx on Ubuntu VPS.
Backups that you can restore (repos + database + config)
Forgejo data lives in two places:
- Database: users, issues, PR metadata, settings
- Filesystem: repositories, attachments, and app config inside
/opt/forgejo/data
A usable backup plan captures both, runs on a schedule, and copies the results off the VPS. Keep at least 7–30 days, depending on how often your repos change.
1) Database dump (Postgres):
cd /opt/forgejo
sudo docker exec -t forgejo-db pg_dump -U forgejo forgejo | gzip > /opt/forgejo/backup/forgejo-db-$(date +%F).sql.gz
2) Filesystem archive (repos + config):
sudo tar -C /opt/forgejo -czf /opt/forgejo/backup/forgejo-data-$(date +%F).tar.gz data
3) Offsite copy (example with rsync to another server):
rsync -av --delete /opt/forgejo/backup/ backupuser@backup-vps:/srv/backups/forgejo/
4) Test a restore quarterly. A backup you’ve never restored is just a file sitting on disk.
The fastest test is to spin up a small VPS, restore into a fresh Compose stack, and confirm you can browse repos and issues.
If you want a deeper look at the “tested restores” mindset, the approach in Set Up PostgreSQL Backups With pg_dump + Restore Test maps cleanly to Forgejo.
Updates: keep it boring, keep it safe
Forgejo upgrades are usually straightforward. What matters is the routine you follow before and after the restart.
- Take a fresh backup (DB + data directory).
- Pull the new images.
- Restart containers.
- Watch logs for migrations and errors.
Commands:
cd /opt/forgejo
sudo docker compose pull
sudo docker compose up -d
sudo docker compose logs -f --tail=200 forgejo
Two habits prevent most upgrade pain:
- Pin versions once you’re stable. “latest” is fine for evaluation, but production teams usually pin a known-good tag and upgrade on purpose.
- Read the release notes for breaking changes. If you see database migration notes, schedule the restart during a quiet window.
If you run several Compose services, automate update hygiene carefully. Watchtower can help, but it shouldn’t replace reading changelogs. This HostMyCode guide shows a controlled setup: Docker Compose Auto-Updates With Watchtower on a VPS.
Operational checks that catch problems early
Most Forgejo outages aren’t caused by Forgejo itself. They usually come from disk pressure, a TLS renewal hiccup, or a database volume going read-only.
A short routine catches the usual suspects:
- Disk: keep 20% free if you can. Git packfiles and DB autovacuum both need breathing room.
- Backups: confirm last night’s files exist and are non-trivial in size.
- Certificate renewal: confirm Certbot timers are active:
systemctl status certbot.timer - Logs: scan Forgejo logs weekly for repeated auth failures or webhook errors.
Disk pressure is the quiet killer on Git servers. Repos grow gradually—until they don’t. If you need a safe cleanup workflow, this diagnostic is a good starting point: Disk Full on VPS: Find Large Files and Free Space Safely.
Choosing where Forgejo runs: VPS vs dedicated
For most teams, Forgejo belongs on a VPS with NVMe storage and a clean backup path. You can scale CPU/RAM without redesigning anything.
That makes the move from “pilot” to “internal standard” pretty painless.
If your org is repo-heavy, stores large LFS objects, or needs strict isolation, a dedicated server can be a better fit. You get guaranteed I/O and more predictable performance during parallel clone/fetch spikes. HostMyCode offers both paths, so you can start small and move up without rebuilding your workflow.
If you want a clean, reliable home for Forgejo, start with a HostMyCode VPS sized for NVMe storage and steady I/O. If you’d rather not spend weekends on patching and platform upkeep, managed VPS hosting keeps the infrastructure work predictable while you focus on shipping code.
FAQ
Does Forgejo replace GitHub completely?
It covers the core Git hosting workflow: repos, pull requests, issues, and access control. What it doesn’t replace is GitHub’s ecosystem—hosted runners, marketplace integrations, and the long tail of third-party tooling built around it.
Should I use Git over HTTPS or SSH?
Use SSH for day-to-day developer work. It’s fast and avoids repeated credential prompts. Keep HTTPS enabled for tokens, automation, and networks where SSH is blocked.
What should I back up for a Forgejo server?
Back up the database and the entire Forgejo data directory. Store backups offsite and test restores. If you only back up repos, you’ll lose issues and pull request history.
Can I put Forgejo behind Cloudflare?
Yes, for HTTPS and web UI behavior. For SSH Git traffic, you’ll still expose your Git SSH port directly (or use an alternative SSH approach). Keep firewall rules explicit and minimal.
How do I know when to move from a VPS to a dedicated server?
Move when disk I/O is clearly your bottleneck (slow clones during peak hours), when you need larger storage pools for LFS, or when you want stricter workload isolation. Forgejo itself doesn’t demand dedicated hardware; your usage patterns do.
Summary: a private Git server that stays manageable
Forgejo is a practical middle ground in 2026: familiar Git hosting features, self-hosted control, and a footprint that doesn’t require a platform team to babysit it. Set it up with HTTPS, a separate SSH port, and backups you can restore.
Done right, it becomes the kind of internal service you rarely think about—which is exactly the goal.
If you’re ready to host it on stable infrastructure, deploy it on a HostMyCode VPS and keep your repos, PRs, and delivery workflow under your own roof.