Self-hosted GitLab: requirements, install and upkeep

Updated

This page contains affiliate links. If you buy through them, this site may earn a commission at no extra cost to you. How affiliate links work here.

Self-hosted GitLab is practical on a single Linux server with at least 8 GB of RAM, though GitLab’s own baseline is 16 GB and 8 vCPU. Install the official Linux package (or the Docker image), let it fetch a Let’s Encrypt certificate, put CI runners on a second machine, and then budget time every month for upgrades, which must follow GitLab’s required upgrade stops. If you only need Git hosting and code review for a few people, a lighter forge or GitLab.com’s free tier is usually the better choice.

Disclosure: this site may earn a commission if you buy from DigitalOcean, Vultr or Hostinger through links on this page. Hetzner pays nothing and is linked normally.

At a glance

Question Answer
Hardware 16 GB RAM and 8 vCPU baseline; 8 GB minimum for small, memory-constrained installs; SSD storage
Database PostgreSQL only, bundled with the Linux package; GitLab 19.x needs PostgreSQL 17 or 18
Install routes Linux package (recommended for a VM), Docker image, Helm chart for Kubernetes
Edition EE package without a licence runs the Free features
Runners Separate machine, Docker executor, never privileged mode for untrusted code
Backups gitlab-backup create plus a separate copy of /etc/gitlab
Upkeep A minor release every month; upgrades must stop at x.2, x.5, x.8 and x.11

What GitLab needs

GitLab’s installation requirements set the numbers for a single-node install:

  • CPU: 8 vCPU as the baseline. ARM processors are supported. Burstable instance types are not recommended.
  • Memory: 16 GB as the baseline. In memory-constrained environments GitLab can run with at least 8 GB.
  • Swap: disable it where possible; if you cannot, give the server enough memory that GitLab never touches it.
  • Storage: 40 GB for the application, plus room for all repositories, plus 5 to 12 GB for PostgreSQL, on SSDs.
  • PostgreSQL: the only supported database. GitLab 19.x needs 17.x to 18.x. The Linux package bundles a matching version, so this matters mainly with an external database.

A separate guide on running GitLab in a memory-constrained environment squeezes an install into about 2.5 GB plus 1 GB of swap by cutting Puma and Sidekiq concurrency and turning off monitoring. That suits one person trying GitLab out, not a team.

Choose an install route

  1. Linux package (formerly Omnibus): one package bundling GitLab, PostgreSQL, Redis and NGINX, managed with gitlab-ctl. The best fit for a VPS, and the route this page follows.
  2. Docker image: the same package inside a container.
  3. Helm chart: a cloud-native Kubernetes deployment. GitLab says production use needs strong working knowledge of Kubernetes plus external PostgreSQL, Redis and object storage.

CE or EE

GitLab’s Community Edition page says the EE package runs with Free features without a paid subscription, and recommends EE for new installs even if you stay on Free; a later subscription only needs an activation code, while CE must be converted first. CE is MIT-licensed; EE falls under GitLab’s EE licence. Backups restore only to the same version and edition.

Install with the Linux package on Ubuntu or Debian

The official guides cover Ubuntu 22.04, 24.04 and 26.04 and Debian 11, 12 and 13. Before you start, point a DNS record such as gitlab.example.com at the server, because the installer uses that name to request a certificate.

Open SSH, HTTP and HTTPS in the firewall, then install curl:

sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo apt update
sudo apt install -y curl

Next comes GitLab’s repository setup script. Before you pipe it into sudo bash, know what it does: it detects your distribution, installs gnupg if missing, saves GitLab’s package signing key in /etc/apt/keyrings/, adds a packages.gitlab.com source list under /etc/apt/sources.list.d/, and runs apt-get update. It installs no GitLab software. You can open the URL and read it first.

curl --location "https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh" | sudo bash

Then install the package. EXTERNAL_URL sets the address GitLab answers on; with an https:// URL, GitLab requests a Let’s Encrypt certificate automatically, which needs inbound port 80 and a hostname that resolves to the server.

sudo EXTERNAL_URL="https://gitlab.example.com" apt install gitlab-ee

For Community Edition, replace gitlab-ee with gitlab-ce in both commands.

First sign-in

Browse to your URL and sign in as root. The password is in /etc/gitlab/initial_root_password. The first gitlab-ctl reconfigure run after 24 hours deletes that file, and package upgrades run reconfigure, so change the password immediately.

Install with Docker instead

The Docker install guide needs a working Docker Engine (not Docker for Windows), a real hostname, and a mail transport agent, because the image has none. Create a data directory, sudo mkdir -p /srv/gitlab, run export GITLAB_HOME=/srv/gitlab, then use this Compose file from the docs:

services:
  gitlab:
    image: gitlab/gitlab-ee:<version>-ee.0
    container_name: gitlab
    restart: always
    hostname: 'gitlab.example.com'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        # Add any other gitlab.rb configuration here, each on its own line
        external_url 'https://gitlab.example.com'
    ports:
      - '80:80'
      - '443:443'
      - '22:22'
    volumes:
      - '$GITLAB_HOME/config:/etc/gitlab'
      - '$GITLAB_HOME/logs:/var/log/gitlab'
      - '$GITLAB_HOME/data:/var/opt/gitlab'
    shm_size: '256m'

Replace <version> with a specific release: the docs say to pin a version in production and keep latest for testing. Port 22 collides with the host’s own SSH server, so the docs recommend moving the host’s SSH to another port first. Read the root password with sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password; the file disappears on the first container restart after 24 hours.

TLS and email

TLS settings live in /etc/gitlab/gitlab.rb. The SSL docs show the Let’s Encrypt integration with an optional contact address:

external_url "https://gitlab.example.com"
letsencrypt['contact_emails'] = ['admin@example.com']

Apply changes with sudo gitlab-ctl reconfigure. Renewal is automatic, and a certificate renews only when it is within 30 days of expiry. GitLab’s docs say the contact address gets expiry alerts, but Let’s Encrypt ended its expiration emails in 2025, so monitor expiry yourself. Ports 80 and 443 must stay reachable from the internet, because validation does not work on non-standard ports. If you bring your own certificate, set letsencrypt['enable'] = false so reconfigure does not replace it.

GitLab sends confirmations, password resets and pipeline notices by email. Many VPS providers block outbound port 25, so relay through a mail provider. The SMTP docs give this generic block:

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.server"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "smtp user"
gitlab_rails['smtp_password'] = "smtp password"
gitlab_rails['smtp_domain'] = "example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
gitlab_rails['gitlab_email_from'] = 'gitlab@example.com'
gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'

On port 465 the docs say gitlab_rails['smtp_tls'] = true must also be set. To keep the password out of gitlab.rb, they describe an encrypted credentials file. Test delivery from gitlab-rails console with Notify.test_email('you@example.com', 'Message Subject', 'Message Body').deliver_now.

Lock down the admin side

You can limit what an attacker can do with the web interface:

  • Sign-ups: by default, anyone who reaches your domain can create an account, and new instances hold those sign-ups for admin approval. For a private server, clear Allow new user accounts under Admin > Settings > General > New user account restrictions, or restrict sign-ups to your email domain.
  • Two-factor authentication: under Sign-in restrictions, turn on Enforce two-factor authentication for administrators, or for everyone.
  • Admin Mode: Admin Mode keeps admin rights switched off until an administrator re-authenticates, for at most six hours per session.
  • Team-only instances: put the whole server behind a VPN such as WireGuard or a firewall IP allowlist.

Add CI runners on a separate machine

GitLab Runner runs your CI/CD jobs. The registration docs say to install it on a server separate from GitLab, and the runner security page explains why: anyone with the Developer role on a project can run code on the runner host. Keep the runner’s major and minor version the same as your GitLab version.

On a Debian or Ubuntu runner host, the install guide downloads the repository script so you can read it before running it. Like the GitLab script, it adds GitLab’s runner repository and signing key to apt:

curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" -o script.deb.sh
less script.deb.sh
sudo bash script.deb.sh
sudo apt install gitlab-runner

Registration now uses runner authentication tokens, which start with glrt-. The older registration tokens are deprecated and scheduled for removal in GitLab 20.0. In GitLab, go to Admin > CI/CD > Runners and create an instance runner (or a project runner under the project’s Settings > CI/CD > Runners), copy the token it shows, then on the runner host:

sudo gitlab-runner register \
  --non-interactive \
  --url "https://gitlab.example.com/" \
  --token "$RUNNER_TOKEN" \
  --executor "docker" \
  --docker-image alpine:latest \
  --docker-pull-policy "if-not-present" \
  --description "docker-runner"

The Docker executor needs Docker Engine on the runner host. GitLab calls it safe in non-privileged mode and advises against privileged mode, which can give a job root access to the host. Use the shell executor only for trusted code. On a runner shared by users with private images, the security page says to use the always or never pull policy instead of if-not-present.

Backups

The backup docs give one command for the application data (repositories, database, uploads):

sudo gitlab-backup create

In Docker, run docker exec -t <container name> gitlab-backup create from the host. To schedule it, the docs suggest this root crontab line, and gitlab_rails['backup_keep_time'] = 604800 in gitlab.rb to keep seven days of local archives:

0 2 * * * /opt/gitlab/bin/gitlab-backup create CRON=1

The archive does not contain /etc/gitlab, which holds gitlab.rb and gitlab-secrets.json, nor TLS or SSH host keys. Without gitlab-secrets.json, GitLab cannot decrypt two-factor secrets or CI/CD variables after a restore. Copy /etc/gitlab separately and store it apart from the archives, since encrypted data next to its key defeats the encryption. Object storage is also skipped. Keep copies off the server and test restores.

Upgrades: follow the path

GitLab ships a minor release on the third Thursday of every month and patch releases on the Wednesdays before and after it; security fixes go to the current release and the two before it, per the maintenance policy. Major versions arrive yearly in May; GitLab 20.0 is scheduled for May 2027.

You cannot jump straight from an old version to the newest. The upgrade paths page lists required stops; from GitLab 17.5 on they fall at x.2, x.5, x.8 and x.11, using the latest patch of each. At every stop, let background migrations finish before moving on. The Upgrade Path tool calculates the stops between your version and the target.

Install each stop by explicit version, as the package upgrade docs show:

sudo apt update && sudo apt install gitlab-ee=<version>-ee.0

The package backs up the database first; keep your own full backup too. Read each release’s notes before upgrading; going monthly keeps every jump small.

VPS sizing and cost

Plan for 8 GB at least, and 16 GB for a team using CI or the container registry.

Provider and plan vCPU RAM Disk Monthly price Source Checked
DigitalOcean Basic Droplet, Regular 4 8 GiB 160 GiB SSD $48.00 digitalocean.com 2026-12-02
DigitalOcean Basic Droplet, Regular 8 16 GiB 320 GiB SSD $96.00 digitalocean.com 2026-12-02
Vultr Cloud Compute, Regular Performance 4 8 GB 160 GB SSD $40.00 Vultr API 2026-12-02
Vultr Cloud Compute, Regular Performance 6 16 GB 320 GB SSD $80.00 Vultr API 2026-12-02
Hetzner CPX32 4 8 GB 160 GB from €30.49 excl. VAT (Helsinki); varies by location hetzner.com 2026-12-02
Hetzner CPX42 8 16 GB 320 GB from €59.49 excl. VAT (Helsinki); varies by location hetzner.com 2026-12-02
Hostinger KVM 2 2 8 GB 100 GB NVMe $14.99, regular price on a 24-month term paid upfront hostinger.com 2026-12-02
Hostinger KVM 4 4 16 GB 200 GB NVMe $28.99, regular price on a 24-month term paid upfront hostinger.com 2026-12-02

The DigitalOcean, Vultr and Hetzner plans use shared vCPUs, and GitLab advises against burstable instances. Hetzner bills hourly with good value in the EU, Vultr and DigitalOcean bill hourly with more regions, and Hostinger is cheapest per GB of RAM if you commit for two years. Budget a second machine for the runner. See the VPS comparison for self-hosting, and total it up with the self-hosting cost calculator.

When not to self-host GitLab

GitLab means monthly upgrades along a fixed path and a bigger server than most self-hosted apps. Consider the alternatives first:

Self-host GitLab when you need its CI/CD, registry and planning tools under your control and someone owns the upgrades. More options are on the Git hosting hub.

Frequently asked questions

How much RAM does self-hosted GitLab need?
GitLab's requirements page gives 16 GB of memory and 8 vCPU as the baseline for a single-node install, and says GitLab can run with at least 8 GB in memory-constrained environments. A separate tuning guide shows a stripped-down setup in about 2.5 GB plus swap, but that disables monitoring and limits concurrency, so treat it as a single-user experiment.
Should I install GitLab CE or EE?
GitLab recommends the Enterprise Edition package for new installs, even if you only plan to use the Free features. Without a subscription it runs with Free features, and a later subscription only needs an activation code. The Community Edition is MIT-licensed, while EE is under GitLab's more restrictive EE licence, so some people prefer CE on principle.
Where is the initial root password?
The Linux package writes a random password to /etc/gitlab/initial_root_password. The first gitlab-ctl reconfigure run after 24 hours deletes the file, and package upgrades run reconfigure, so sign in as root and change it straight away. In Docker, the file is deleted on the first container restart after 24 hours.
Can I skip GitLab versions when upgrading?
Only up to the next required upgrade stop. Since GitLab 17.5, stops fall on the x.2, x.5, x.8 and x.11 minor versions, and you must let background migrations finish at each one. GitLab's Upgrade Path tool lists the exact versions between your current and target release.
Does gitlab-backup create back up everything?
No. It skips /etc/gitlab, including gitlab-secrets.json and gitlab.rb, plus TLS and SSH host keys, and anything stored in object storage. Without gitlab-secrets.json GitLab cannot decrypt 2FA secrets or CI/CD variables in a restored database, so copy that file separately and keep it away from the backup archives.

Sources, checked December 2, 2026

  1. GitLab Docs: Installation requirements
  2. GitLab Docs: Install the Linux package on Ubuntu
  3. GitLab Docs: Install the Linux package on Debian
  4. GitLab CE apt repository setup script (script.deb.sh)
  5. GitLab Docs: Install GitLab in a Docker container
  6. GitLab Docs: GitLab Helm chart
  7. GitLab Community Edition (CE) and choosing EE
  8. GitLab Docs: Licensing and compatibility (CE under MIT, EE licence)
  9. GitLab Docs: Running GitLab in a memory-constrained environment
  10. GitLab Docs: Configure SSL for a Linux package installation
  11. Let's Encrypt: Expiration emails (service shut down)
  12. GitLab Docs: SMTP settings
  13. GitLab Docs: Sign-up restrictions
  14. GitLab Docs: Sign-in restrictions (Admin Mode)
  15. GitLab Docs: Enforce two-factor authentication
  16. GitLab Runner Docs: overview and version compatibility
  17. GitLab Runner Docs: Install from the official GitLab repositories
  18. GitLab Runner Docs: Registering runners
  19. GitLab Docs: Manage runners (create instance and project runners)
  20. GitLab Runner Docs: Security for self-managed runners
  21. GitLab Docs: Back up GitLab
  22. GitLab Docs: Upgrade paths
  23. GitLab Support: Upgrade Path tool
  24. GitLab Docs: Upgrade a Linux package instance
  25. GitLab Docs: Release and maintenance policy
  26. GitLab Docs: Free user limit on GitLab.com
  27. Codeberg Docs: What is Codeberg?
  28. DigitalOcean Droplet pricing
  29. Vultr API: list plans (Regular Performance, vc2)
  30. Hetzner Cloud Regular Performance plans
  31. Hostinger VPS hosting plans

More in Git hosting