Forgejo is a self-hosted Git service. Use it to manage repositories in your browser, work with issues and pull requests, use wikis, releases, and package management, and automate tests or builds with Forgejo Actions. Its interface is reminiscent of GitHub, but your data stays on your own server. This guide shows you two ways to get started: the easy way, as a One-Click App that makes Forgejo available over HTTPS in just a few clicks, and the manual installation with Docker Compose. After that, you'll create your first repository, clone it over HTTPS or SSH, and, if needed, mirror projects from GitHub.
Running your own Git server with Forgejo is worthwhile if:
- You don't want your code hosted by a third-party provider, for example for private projects, customer projects, or configuration files.
- You want to bring a small team or multiple projects together, with users, organizations, and permissions for each repository.
- You want to keep a copy of your GitHub or GitLab projects: Forgejo can import repositories and keep mirrors up to date automatically.
- Free software and community-led development matter to you. Forgejo is developed under the umbrella of the non-profit organization Codeberg e.V.
Forgejo is less suitable if you're looking for a complete DevOps platform with security scans and large CI/CD pipelines. GitLab is better suited to that, but requires significantly more memory. See Install GitLab.
Forgejo started as a fork of Gitea in October 2022. The two are very similar in everyday use; even Forgejo's internal data directory is still called gitea.
| Forgejo | Gitea | |
|---|---|---|
| Origin | Fork of Gitea, developed under the umbrella of the non-profit organization Codeberg e.V. | Independent project, originally a fork of Gogs |
| User experience | Very similar to Gitea | Very similar to GitHub |
| Resource requirements | Low | Low |
| CI/CD | Forgejo Actions with its own runner | Gitea Actions with its own runner |
| One-Click App | 8 variants, including one with a preconfigured runner | 4 variants, runner available as a separate app |
Both work well for running your own small Git server. If you prefer Gitea, see the Install Gitea guide. According to the Forgejo documentation, you can migrate from Gitea up to version 1.22 in two steps via Forgejo 10.
The fastest way to get Forgejo is through the One-Click Apps on your VPS. The app is accessible directly over HTTPS using a domain, so you don't need a reverse proxy or certificate. The app also makes port 22222 available for git clone over SSH.
The app catalog offers Forgejo in eight variants. They differ in their database and whether they include a runner for Forgejo Actions:
| Variant | Database | Runner |
|---|---|---|
| Forgejo | SQLite, a single file in the data volume | No |
| Forgejo with PostgreSQL | PostgreSQL 16 | No |
| Forgejo with MariaDB | MariaDB 11 | No |
| Forgejo with MySQL | MySQL 8 | No |
| Forgejo with Runner (also available with PostgreSQL, MariaDB, or MySQL) | As above | Yes |
The Forgejo variant with SQLite is enough for you or a small team. If you expect many users and repositories, or prefer a dedicated database, choose Forgejo with PostgreSQL. To run workflows with Forgejo Actions directly on the server, choose a with Runner variant (see below). You can't easily switch variants later, so choose one before installing.
- A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. See Set up One-Click Apps for instructions.
- Sufficient resources: In our test, Forgejo with SQLite used around 250 MB of memory while idle. Allow for significantly more if you're using a database, many repositories, or a runner, since the runner starts separate containers for each job.
- Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
- Search the app catalog for Forgejo, choose the variant you want, and click Install app.
- Use a custom subdomain or zap.cloud is already selected, with a randomly generated name. Leave it selected or enter your own name: Forgejo will be accessible over HTTPS at this domain and will use it for HTTPS and SSH clone URLs.
- Under App configuration, you'll find only optional fields, which you can leave as they are:
FORGEJO_SSH_PORT(default22222),FORGEJO__migrations__ALLOWED_DOMAINS(empty means migrations are allowed from all addresses), andFORGEJO__migrations__ALLOW_LOCALNETWORKS(defaultfalse). The app generates the database credentials itself. - Click Queue installation. After one to two minutes, Forgejo will appear online on the app card. Under Connection, the card also shows the IP address with SSH port
22222.
The variants without a runner don't come with preset login credentials. The first time you open Forgejo, you'll see the Initial configuration page. Whoever submits it first sets up Forgejo and creates the administrator account.
Open Forgejo right after installation Until you complete the initial setup, anyone who knows the address can open the Initial configuration page. Open the app's Access link as soon as the app is online.
- Open the app's Access link.
- Leave the database fields at the top unchanged. The Forgejo variant shows SQLite3; the database variants have their connection details configured by the app.
- Under General settings, check the prefilled values: Server domain is your domain, SSH server port is set to
22222, and Base URL is set tohttps://followed by your domain. Leave these values as they are. - Disable self-registration is already checked. This means only administrators can create new accounts. Leave it checked if you don't want to run a public instance.
- Expand Administrator account settings and enter a username, email address, and long password.
- Click Install Forgejo. After a few seconds, you'll be signed in as the administrator.
If you leave Administrator account settings empty, the first account registered afterward becomes the administrator. The settings are stored in /data/gitea/conf/app.ini in the data volume. Unlike Gitea, Forgejo's SSH clone URLs are correct out of the box: in our test, they looked like ssh://git@git.example.com:22222/USER/REPO.git without any additional configuration.
SSH port 22222
If you use your own firewall on the server, allow port 22222/tcp. Only one app per VPS can use this port. If you also install Gitea or a second Forgejo instance, enter a different value for FORGEJO_SSH_PORT under App configuration for one of them.
According to the app recipe, the initial setup is already complete for with Runner variants. The app creates the administrator account automatically. You can find the username and password in the app settings (gear icon) under App environment > Automatically generated values. The app also starts a Forgejo Runner in its own Docker environment and registers it with Forgejo automatically. In these variants, new repositories initially show only Code and Actions. You can enable issues, pull requests, or the wiki in the repository under Settings > Units.
Update Forgejo in the app settings (gear icon) under App update. Click Check for updates, then install a new version with Apply update. If the app says it's up to date, there's no newer version in the app catalog yet. The app uses Forgejo 17.
Repositories, users, and settings are stored in Docker volumes and are preserved during updates. However, a volume is not a backup. Forgejo provides the forgejo dump command, which packages repositories, the database, and the configuration into a ZIP file. Run this over SSH on your VPS:
C=$(docker ps --format '{{.Names}}' | grep '^forgejo-')
docker exec -u git -w /tmp $C bash -c 'forgejo dump -c /data/gitea/conf/app.ini'
docker exec $C sh -c 'ls /tmp/forgejo-dump-*.zip'
Copy the displayed file to the server with docker cp $C:/tmp/FILENAME.zip ., then transfer it from there to your computer over SFTP. The Forgejo documentation strongly recommends not using Forgejo during a backup. At a minimum, make sure nobody pushes during this time so the repositories and database remain in sync.
The rest of this guide covers the manual installation of Forgejo with Docker Compose, following the official Forgejo documentation. This is useful, for example, if you don't use One-Click Apps on your server or want to manage everything yourself.
- A Linux VPS running Debian or Ubuntu, with SSH access. See First access via SSH.
- Docker and Docker Compose. See Install Docker. Check the installation with
docker --versionanddocker compose version. - For HTTPS: a domain or subdomain with an A record pointing to your VPS's IP address (e.g.,
git.example.com).
| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 1 core | 2 cores |
| RAM | 512 MB | 1 GB or more |
| Storage | System, images, and your repositories | Additional space for growth and backups |
Forgejo doesn't specify fixed minimum requirements in its documentation. The table is based on our test, where Forgejo with SQLite used around 250 MB of memory while idle. Allow for more if you're running a dedicated database or a runner on the same server.
Forgejo uses port 3000 for the web interface and port 22 inside the container for SSH. The web interface is accessed through the reverse proxy, so you don't need to open port 3000. As in the Forgejo documentation, we'll use port 222 on the server for SSH, because port 22 is already used for the server's SSH access. With ufw, allow only what you need:
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 222/tcp
ufw enable
Docker bypasses ufw
Ports published by Docker with ports: are accessible from the internet even if they're blocked by ufw. So, as in the Compose file below, bind the web interface to 127.0.0.1 only. See Firewall management on Linux for more about firewalls.
Create a directory for Forgejo. According to the documentation, the data directory must belong to the user Forgejo runs as; otherwise, the container may not start:
mkdir -p /opt/forgejo/forgejo
chown 1000:1000 /opt/forgejo/forgejo
cd /opt/forgejo
Create the Compose file with nano docker-compose.yml. It follows the Forgejo documentation's example using SQLite:
networks:
forgejo:
external: false
services:
server:
image: codeberg.org/forgejo/forgejo:17
container_name: forgejo
environment:
- USER_UID=1000
- USER_GID=1000
- FORGEJO__server__DOMAIN=git.example.com
- FORGEJO__server__ROOT_URL=https://git.example.com/
- FORGEJO__server__SSH_DOMAIN=git.example.com
- FORGEJO__server__SSH_PORT=222
restart: always
networks:
- forgejo
volumes:
- ./forgejo:/data
- /etc/localtime:/etc/localtime:ro
ports:
- "127.0.0.1:3000:3000"
- "222:22"
Here's what the entries mean:
image: Forgejo major version 17, as used by the One-Click App. The17tag always points to the latest update within this version. You'll need to upgrade to the next major version yourself.USER_UIDandUSER_GID: Forgejo creates its files in theforgejodirectory using this user ID and group ID.FORGEJO__server__...: The public address, name, and port used in clone URLs. Replacegit.example.comwith your domain. Use the patternFORGEJO__<section>__<key>to set any option fromapp.ini.127.0.0.1:3000:3000: The web interface is accessible only from the server itself; external access goes through the reverse proxy.222:22: Server port222forwards to the SSH service inside the container.
Without any additional settings, Forgejo uses SQLite. To use PostgreSQL or MySQL, add a db service and the FORGEJO__database__DB_TYPE, HOST, NAME, USER, and PASSWD lines, following the database example in the documentation.
Start the container:
docker compose up -d
Check whether it's running with docker compose ps and view the logs with docker compose logs -f.
Because the web interface listens only on 127.0.0.1, it's best to set up the reverse proxy in the next section first, then access Forgejo at https://git.example.com. Alternatively, open the page using an SSH tunnel from your computer:
ssh -L 3000:localhost:3000 root@SERVER_IP
Replace SERVER_IP with your VPS's IP address and open http://localhost:3000 in your browser. The Initial configuration page will appear. Check that your domain is under Server domain, 222 is under SSH server port, and your HTTPS address is under Base URL. Keep Disable self-registration checked, create your admin account under Administrator account settings, and click Install Forgejo.
To access Forgejo externally, put a reverse proxy with a valid certificate in front of it. For the basics, see Set up a reverse proxy with nginx and Create an SSL certificate (Let's Encrypt). Here's an nginx server block based on the example in the Forgejo documentation:
server {
listen 80;
listen [::]:80;
server_name git.example.com;
merge_slashes off;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Connection $http_connection;
proxy_set_header Upgrade $http_upgrade;
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;
client_max_body_size 512M;
}
}
Forgejo needs merge_slashes off for URLs containing encoded slashes. client_max_body_size allows larger uploads; otherwise, nginx will stop them with the error “413 Request Entity Too Large.” Then obtain the certificate with certbot --nginx -d git.example.com. Certbot adds HTTPS and redirects HTTP to the server block. Find more tips on securing your server in Linux security tips.
All data is stored in the forgejo directory alongside the Compose file; with SQLite, the database is there too. The forgejo/gitea/conf/app.ini file is also important: it contains keys that Forgejo needs to read stored secrets, such as two-factor authentication settings or Actions secrets, after a restore. The documentation strongly recommends stopping Forgejo before creating a backup:
cd /opt/forgejo
docker compose stop
tar -czf /root/forgejo-backup-$(date +%F).tar.gz forgejo docker-compose.yml
docker compose start
Then copy the archive to another storage location. If you use PostgreSQL or MySQL, also back up the database with its own tools, such as pg_dump.
To install updates within major version 17, run:
cd /opt/forgejo
docker compose pull
docker compose up -d
To upgrade to a new major version, for example from 17 to 18, the Forgejo documentation requires a full backup. First, read the upgrade guide and the notes for the relevant version. Then update the tag in docker-compose.yml and restart as above. Afterward, check that everything is working:
docker exec -u git forgejo forgejo doctor check --all
Remove old images with docker image prune.
After setup, create your first repository by clicking the plus icon in the top-right corner > New repository. Select Initialize repository to have Forgejo create a README file so you can clone the repository right away.
You can find the clone URL in the repository by clicking HTTPS in the top-right corner:
git clone https://git.example.com/USER/REPO.git
Git will ask for your Forgejo username and password. If you've enabled two-factor authentication, use an access token generated under Settings > Applications instead of your password.
To use SSH, add your public key once under Settings > SSH / GPG keys > Add key. See Create an SSH key for instructions on generating a key pair. You can find the address by clicking SSH:
git clone ssh://git@git.example.com:22222/USER/REPO.git
The port is 22222 for the One-Click App and 222 for a manual installation. In our test, cloning and pushing worked both ways.
Use the plus icon > New migration to import repositories from GitHub, GitLab, Gitea, Forgejo, and other services. Select This repository will be a mirror to have Forgejo automatically fetch updates from the source on a regular basis. In the repository, click Synchronize now under Settings to sync immediately. In our test, we were able to mirror a public GitHub repository without entering anything else. For private repositories, provide an access token from the source. You can't turn an existing repository into a mirror afterward. Conversely, Forgejo can also push to another destination under Settings > Repository, in the Mirror settings section.
Create workflows with Forgejo Actions in the repository's .forgejo/workflows directory, similar to GitHub Actions. In our test, new repositories showed the Actions tab immediately. However, workflows aren't run by Forgejo itself; they're run by a Forgejo Runner:
- As a One-Click App: Choose a with Runner variant. According to the app recipe, the runner registers itself and provides the
docker(Node.js 22),ubuntu-latest, andubuntu-22.04labels. - Manual installation: Install the runner by following the runner documentation. You can find a registration token in the administration area under Admin settings > Actions > Runners (at
/admin/actions/runners).
A runner executes third-party code. The Forgejo documentation explicitly warns about this risk, so only use runners for repositories you trust. Without a connected runner, workflows stay in the queue.
- Storage space: Repositories, releases, LFS files, and packages use storage on your VPS. If you run out of space, increase it in the Manage plan tab for your VPS.
- Email: Without a mail server, Forgejo can't send notifications or password reset links. Enter the details during initial setup under Email settings, or later using
FORGEJO__mailer__variables. - Database variant: You can't switch the One-Click App from SQLite to PostgreSQL with a single click.
You've set up Forgejo on your VPS, created an admin account, and learned how to clone repositories over HTTPS and SSH, mirror projects from GitHub, and back up your data. You now have your own lightweight Git server that runs well even on small servers.
Prefer not to deal with Docker manually? Use the easy One-Click App option described above under “The easy way: Forgejo as a One-Click App.”