How to add a subdomain to an existing certificate using certbot
How to add a subdomain to an existing certificate using certbot: find the certificate name, expand it with --cert-name, confirm it and avoid duplicates.

To add a subdomain to an existing certificate using certbot, run certbot with --cert-name set to the certificate’s name and -d listing every domain it should cover, old and new: sudo certbot --apache --cert-name example.ca -d example.ca,www.example.ca,staging.example.ca. Certbot replaces the certificate with one that covers all three names.
This guide assumes certbot already issued a Let’s Encrypt certificate on your Apache server. If you don’t have one yet, start with our guide to installing an SSL certificate with certbot on Ubuntu and Apache. The commands follow the certbot user guide, as of November 2026.
In our example, the certificate covers example.ca and www.example.ca, and we want to add staging.example.ca, a staging copy of the site served from another folder on the same server.
Step 1: Find the certificate name and its domains
List the certificates certbot manages. Each one has a name, which you pass to --cert-name, and a list of domains:
sudo certbot certificatesThe output looks like this (shortened):
Found the following certs:
Certificate Name: example.ca
Domains: example.ca www.example.ca
Certificate Path: /etc/letsencrypt/live/example.ca/fullchain.pem
Private Key Path: /etc/letsencrypt/live/example.ca/privkey.pemNote the certificate name (example.ca) and copy the full list of domains. You will need both in step 3.
Step 2: Point the subdomain to the server and give it a virtual host
Certbot can only add a subdomain that already reaches your server. Before you run it, check two things:
DNS: an A record (and AAAA for IPv6) for
staging.example.capoints to the server.dig +short staging.example.cashould print the server’s IP address.Apache: a
<VirtualHost *:80>block withServerName staging.example.cais enabled, so the Apache plugin can complete the HTTP-01 challenge on port 80 and knows where to install the certificate.
If the subdomain doesn’t have a virtual host yet, follow our guide to setting up a subdomain on the same Apache web server first.
Step 3: Add the subdomain with certbot --cert-name
Run certbot with the certificate name and the complete list of domains, the old ones plus the new subdomain:
sudo certbot --apache --cert-name example.ca -d example.ca,www.example.ca,staging.example.caCertbot proves control of each name, replaces the example.ca certificate with one that holds all three, and deploys it to the matching Apache virtual hosts. The file paths under /etc/letsencrypt/live/example.ca/ stay the same, so the rest of your configuration keeps working.
The -d list is the complete new list, not an addition. Certbot’s guide to changing a certificate’s domains shows the same flag removing a domain when it’s left out. If you forget www.example.ca here, it disappears from the certificate.
How does certbot --expand work?
--expand also adds names to an existing certificate, but only when you list every domain already on it plus the new ones. The equivalent command is:
sudo certbot --apache --expand -d example.ca,www.example.ca,staging.example.caThe certbot docs suggest --cert-name instead, because it names the certificate you mean and can remove domains as well as add them. Use --expand only if you have a script that already relies on it.
The first version of this guide used sudo certbot -d staging.example.ca --expand. That command doesn’t touch the example.ca certificate: because staging.example.ca alone isn’t a superset of any existing certificate, certbot issues a separate certificate named staging.example.ca. The certbot certificates output we showed back then proved it, with three separate certificates instead of one.
Step 4: Confirm the subdomain is on the certificate
List the certificates again. The example.ca entry should now show all three domains:
sudo certbot certificates Certificate Name: example.ca
Domains: example.ca www.example.ca staging.example.caThen test renewal and open https://staging.example.ca in a browser. It should load with the padlock and no warning.
sudo certbot renew --dry-runShould you expand the certificate or issue a separate one?
Expand the certificate when the subdomain lives on the same server and will stay there. Issue a separate certificate when it might move. Use this rule:
Same server, same owner (staging, shop, help pages): add it to the main certificate with
--cert-name. One certificate, one renewal.The subdomain may move to another server or team: give it its own certificate with
sudo certbot --apache -d staging.example.ca, so moving it later doesn’t mean editing the main certificate.Many subdomains: a wildcard certificate (
*.example.ca) covers them all, but it needs the DNS-01 challenge and a DNS plugin, not--apache.
Every name on a certificate is visible to anyone who inspects it. If you’d rather not show staging.example.ca on your main site’s certificate, issue it separately.
How to remove a duplicate subdomain certificate
If you ran the old --expand command and now have both a separate staging.example.ca certificate and an expanded example.ca one, delete the duplicate. First make sure Apache no longer points to it, as certbot’s safe-deletion steps require:
sudo grep -R live/staging.example.ca /etc/apache2If the command prints nothing, delete the certificate. If it prints a file, change that file’s SSLCertificateFile and SSLCertificateKeyFile lines to the example.ca paths and reload Apache first.
sudo certbot delete --cert-name staging.example.caDeleting a certificate can’t be undone, which is why the check comes first.
Frequently asked questions
Does adding a subdomain reset the certificate’s expiry date?
Yes. Certbot requests a new certificate for the full list of names, so the lifetime starts again from the day you add the subdomain. Automatic renewal carries on as before.
How many domains can one Let’s Encrypt certificate hold?
Up to 100 names, depending on the certificate profile, according to Let’s Encrypt’s rate limits. For a handful of subdomains on one server, one certificate is simpler to manage.
Can I remove a domain from a certificate with certbot?
Yes. Run the same --cert-name command with a shorter -d list. Certbot issues a certificate that holds only the names you list.
Can I add a subdomain without certbot changing my Apache files?
Yes. Use sudo certbot certonly --apache --cert-name example.ca -d example.ca,www.example.ca,staging.example.ca. Certbot updates the certificate but leaves the Apache configuration alone; reload Apache with sudo systemctl reload apache2 afterwards.
If you still need a domain name to hang subdomains from, WHC sells .ca and other domains from Canada. Running more than one site on a server? Our guides to installing WordPress on an Ubuntu VPS and why businesses choose a VPS cover the rest of the setup.
Need help with certificates on your server? Talk to msmtech.