A self-managed GitLab server installed with the Linux (Omnibus) package can get and renew free TLS certificates from Let's Encrypt by itself. You point a public DNS record at the server, set an https:// external URL and the Let's Encrypt options in /etc/gitlab/gitlab.rb, then run gitlab-ctl reconfigure. This page adds the exact configuration, the prerequisites, how to check and renew the certificate, and fixes for the most common errors.
Step 1 – Create a valid DNS entry
Step 2 – Do following changes


Step 3 – Run following commands
$ sudo gitlab-ctl reconfigure
How the built-in Let's Encrypt integration works
The GitLab Linux package bundles an ACME client that runs during gitlab-ctl reconfigure. It requests a certificate for the hostname in external_url and proves you control that hostname with the HTTP-01 challenge. Let's Encrypt connects to http://<your-host>/.well-known/acme-challenge/... on port 80, and GitLab's bundled NGINX serves the token.
When validation succeeds, the certificate and key are written to /etc/gitlab/ssl/<hostname>.crt and /etc/gitlab/ssl/<hostname>.key, and NGINX is reconfigured to serve HTTPS. Let's Encrypt certificates are valid for 90 days, so GitLab also sets up a scheduled renewal job.
Note: If external_url starts with https:// and no certificate files already exist in /etc/gitlab/ssl, the package turns Let's Encrypt on automatically. If certificates from an earlier manual setup are present, you must set letsencrypt['enable'] = true explicitly.
Prerequisites
- GitLab installed with the official Linux package (Omnibus) or the official Docker image. Source installations and Helm chart deployments use different methods.
- A fully qualified domain name, for example
gitlab.example.com, with a public DNS A record (and an AAAA record if you use IPv6) pointing to the server's public IP address. - Inbound TCP port 80 and port 443 open from the internet, in the host firewall and in any cloud security group. Port 80 is required for validation even if you only plan to serve HTTPS.
- A working email address for expiry and account notices from Let's Encrypt.
Check DNS and the firewall before you change GitLab. Run the first command from a machine outside your network:
# The answer must be the server's public IP address
dig +short gitlab.example.com
# Ubuntu with ufw
sudo ufw allow http
sudo ufw allow https
sudo ufw status
# RHEL / Rocky / Alma with firewalld
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reloadCode language: PHP (php)
Configure gitlab.rb
The screenshots in Step 2 above show the edits to /etc/gitlab/gitlab.rb. Here they are as text you can copy. Open the file with sudo vi /etc/gitlab/gitlab.rb (or another editor), then set or uncomment these lines:
## Must use https and the exact DNS name from Step 1
external_url 'https://gitlab.example.com'
## Let's Encrypt integration
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['admin@example.com']
## Automatic renewal (runs as a cron job)
letsencrypt['auto_renew'] = true
letsencrypt['auto_renew_hour'] = 0
letsencrypt['auto_renew_minute'] = 30
letsencrypt['auto_renew_day_of_month'] = "*/4"
## Send plain HTTP traffic to HTTPS
nginx['redirect_http_to_https'] = trueCode language: PHP (php)
external_urlsets the hostname on the certificate. Thehttps://scheme is what makes GitLab listen on 443 and request a certificate.letsencrypt['contact_emails']is the address registered with your Let's Encrypt account.- The
auto_renew_*settings make GitLab try a renewal at 00:30 every fourth day. A certificate is only replaced when it is close to expiry, so frequent checks are safe. nginx['redirect_http_to_https']keeps port 80 open for the ACME challenge and redirects all other requests to HTTPS.
If you also serve the container registry on its own hostname, give it an https URL as well, for example registry_external_url 'https://registry.example.com'. That hostname also needs a DNS record that points to this server.
Apply the change and verify the certificate
- Run
sudo gitlab-ctl reconfigureas shown in Step 3 above. Watch for theletsencryptandacme_certificateresources in the output. The run fails with an error if validation fails. - Confirm the certificate files exist:
sudo ls -l /etc/gitlab/ssl/. - Check the issuer and validity dates from another machine with the
opensslcommand below. - Open
https://gitlab.example.comin a browser. You should see a valid padlock without a warning.
echo | openssl s_client -connect gitlab.example.com:443 -servername gitlab.example.com 2>/dev/null \
| openssl x509 -noout -subject -issuer -dates
# Expected output (values will differ):
# subject=CN = gitlab.example.com
# issuer=C = US, O = Let's Encrypt, CN = ...
# notBefore=...
# notAfter=... (about 90 days later)Code language: PHP (php)
Note: After you switch to HTTPS, update existing Git remotes, webhooks and runner registrations that still use the http:// URL. Redirects do not always work for API clients or git push.
Renewal
With auto_renew enabled, GitLab adds a root cron entry that renews the certificate. You can view it and trigger a renewal yourself:
# Show the renewal cron entry created by GitLab
sudo crontab -l
# Renew now (only replaces the certificate if it is due)
sudo gitlab-ctl renew-le-certsCode language: PHP (php)
Renewal uses the same HTTP-01 challenge. If you close port 80 or change DNS after the first certificate is issued, renewal will fail silently until the certificate expires. Check the expiry date as part of your regular monitoring.
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Reconfigure fails with a connection refused or timeout during validation | Port 80 is blocked by the host firewall, a cloud security group or the ISP | Open TCP 80 to the internet and run sudo gitlab-ctl reconfigure again |
Validation error mentioning DNS or NXDOMAIN | The DNS record does not exist yet or has not propagated | Create the A record, wait until dig +short returns the public IP, then retry |
| Validation returns 404 or reaches the wrong server | DNS points to a different IP, or a load balancer or proxy in front of GitLab does not forward /.well-known/acme-challenge/ | Fix the record, or terminate TLS on the proxy and disable GitLab's Let's Encrypt |
| Let's Encrypt is never requested | Old certificate files are already in /etc/gitlab/ssl, or external_url still uses http:// | Set letsencrypt['enable'] = true, move the old files out of the way and check external_url |
| Error about too many certificates or failed authorizations | Let's Encrypt rate limits were hit after repeated failed attempts | Fix the root cause first, then wait for the rate-limit window to reset before retrying |
| Browser still shows the old or self-signed certificate | NGINX did not reload, or the browser cached the old certificate | Run sudo gitlab-ctl restart nginx and test again with openssl s_client |
Internal servers, proxies and Docker
- Server not reachable from the internet: HTTP-01 validation cannot work. Get a certificate with the DNS-01 challenge using an external ACME client such as certbot with a DNS plugin, or use a certificate from an internal CA. Then set
letsencrypt['enable'] = falseand pointnginx['ssl_certificate']andnginx['ssl_certificate_key']at the files. - Behind a load balancer or reverse proxy that terminates TLS: handle certificates on the proxy. Set
letsencrypt['enable'] = false,nginx['listen_https'] = falseandnginx['listen_port'] = 80so GitLab serves plain HTTP behind the proxy. - Docker: put the same settings in the
GITLAB_OMNIBUS_CONFIGenvironment variable or in the mounted/etc/gitlab/gitlab.rb. Publish ports 80 and 443 on the host and mount/etc/gitlabas a persistent volume so the certificates survive container restarts.
docker run -d --name gitlab --hostname gitlab.example.com \
-p 80:80 -p 443:443 -p 2222:22 \
-e GITLAB_OMNIBUS_CONFIG="external_url 'https://gitlab.example.com'; letsencrypt['enable'] = true; letsencrypt['contact_emails'] = ['admin@example.com']" \
-v /srv/gitlab/config:/etc/gitlab \
-v /srv/gitlab/logs:/var/log/gitlab \
-v /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ee:latestCode language: JavaScript (javascript)
Corrections and missing steps in the original
- Step 1 does not say which record to create. It must be a public A (or AAAA) record whose name exactly matches the hostname in
external_url. - Step 2 shows the configuration only as screenshots, which cannot be copied and may differ between versions. The text version is in the configure section above.
- The original leaves out the port 80 requirement. It is the most common reason the first
gitlab-ctl reconfigurefails. - The original has no verification or renewal steps. Without them a failed renewal goes unnoticed until the certificate expires after 90 days.
Frequently asked questions
Does GitLab renew Let's Encrypt certificates automatically?
Yes, when letsencrypt['auto_renew'] = true is set. GitLab creates a cron job that runs gitlab-ctl renew-le-certs on the schedule you configure. Port 80 must stay reachable from the internet for renewal to succeed.
Can I use Let's Encrypt with a GitLab server on a private network?
Not with the built-in integration, because it uses the HTTP-01 challenge, which needs Let's Encrypt to reach your server on port 80. Get the certificate with a DNS-01 client such as certbot with a DNS plugin, then configure it in GitLab as a manual certificate.
Where does GitLab store the Let's Encrypt certificate?
In /etc/gitlab/ssl/, named after the hostname, for example gitlab.example.com.crt and gitlab.example.com.key. Include /etc/gitlab in your backups, because the standard GitLab backup does not cover it.
Why does gitlab-ctl reconfigure fail at the acme_certificate step?
Usually DNS does not yet point to the server, or port 80 is blocked by a firewall or security group. Check both from outside your network, fix the problem and run reconfigure again. Avoid retrying many times in a row, or you may hit Let's Encrypt rate limits.
Can I get a wildcard certificate with GitLab's built-in Let's Encrypt support?
No. Wildcard certificates require the DNS-01 challenge, which the built-in integration does not perform. Get a wildcard certificate with an external ACME client and configure it manually.
Related tutorials
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals