
How to Use Certbot Standalone Mode to Retrieve Let’s Encrypt SSL Certificates on Ubuntu 24
Managing SSL certificates on Ubuntu servers can be a real pain, especially when you’re dealing with multiple sites and renewal headaches. That’s where Certbot’s standalone mode comes in clutch – it’s a straightforward way to grab Let’s Encrypt certificates without needing Apache or Nginx to be configured first. This guide will walk you through the entire process of setting up Certbot standalone mode on Ubuntu 24, including the gotchas that’ll save you hours of debugging.
How Certbot Standalone Mode Works
Certbot standalone mode essentially fires up its own lightweight web server on port 80 (and sometimes 443) to handle the ACME challenge process. When Let’s Encrypt needs to verify that you actually control the domain you’re requesting a certificate for, it sends a challenge that Certbot answers by serving specific files from its temporary web server.
The process breaks down like this:
- Certbot temporarily binds to port 80
- Let’s Encrypt sends HTTP-01 challenges to your domain
- Certbot serves the challenge responses
- Let’s Encrypt validates your domain ownership
- Certificate gets issued and saved locally
- Certbot shuts down its temporary server
This approach is particularly useful when you’re setting up a fresh server, need certificates before configuring your web server, or want to manage certificates independently of your web server configuration.
Prerequisites and Initial Setup
Before diving in, make sure your Ubuntu 24 system meets these requirements:
- Root or sudo access
- Port 80 available (no other web server running)
- Domain name pointing to your server’s IP
- Firewall configured to allow HTTP traffic
First, update your package list and install Certbot:
sudo apt update
sudo apt install certbot -y
Verify the installation:
certbot --version
You should see something like certbot 2.8.0
or newer. Ubuntu 24 ships with a recent version that includes all the latest security patches.
Step-by-Step Certificate Generation
Now for the main event. Here’s how to generate your first SSL certificate using standalone mode:
sudo certbot certonly --standalone -d yourdomain.com -d www.yourdomain.com
During the first run, Certbot will ask for your email address and agreement to terms. Here’s what a typical session looks like:
$ sudo certbot certonly --standalone -d example.com -d www.example.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices): admin@example.com
Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf
Do you agree to the Terms of Service? (Y)es/(N)o: Y
Would you be willing to share your email address with EFF? (Y)es/(N)o: N
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem
For multiple domains that aren’t subdomains of each other:
sudo certbot certonly --standalone -d domain1.com -d domain2.com -d api.domain3.com
The certificates end up in /etc/letsencrypt/live/
with the following structure:
cert.pem
– The domain certificatechain.pem
– Let’s Encrypt chain certificatefullchain.pem
– cert.pem + chain.pemprivkey.pem
– Certificate private key
Handling Port Conflicts and Common Issues
The biggest headache you’ll run into is port 80 conflicts. If you’re running Apache, Nginx, or any other service on port 80, Certbot standalone will fail with:
Problem binding to port 80: Could not bind to IPv4 or IPv6.
Here are your options:
Option 1: Temporarily stop your web server
# For Apache
sudo systemctl stop apache2
sudo certbot certonly --standalone -d yourdomain.com
sudo systemctl start apache2
# For Nginx
sudo systemctl stop nginx
sudo certbot certonly --standalone -d yourdomain.com
sudo systemctl start nginx
Option 2: Use a different port with manual DNS verification
sudo certbot certonly --manual --preferred-challenges dns -d yourdomain.com
Option 3: Use webroot mode instead
sudo certbot certonly --webroot -w /var/www/html -d yourdomain.com
Automating Certificate Renewal
Let’s Encrypt certificates expire every 90 days, so automation is crucial. The good news is that Ubuntu 24’s Certbot package sets up a systemd timer automatically, but it’s worth checking:
sudo systemctl status certbot.timer
If it’s not active, enable it:
sudo systemctl enable --now certbot.timer
For standalone mode with running web servers, you’ll need a custom renewal hook. Create this script at /etc/letsencrypt/renewal-hooks/pre/stop-webserver.sh
:
#!/bin/bash
systemctl stop nginx # or apache2
And this one at /etc/letsencrypt/renewal-hooks/post/start-webserver.sh
:
#!/bin/bash
systemctl start nginx # or apache2
systemctl reload nginx # reload to pick up new certs
Make them executable:
sudo chmod +x /etc/letsencrypt/renewal-hooks/pre/stop-webserver.sh
sudo chmod +x /etc/letsencrypt/renewal-hooks/post/start-webserver.sh
Test the renewal process:
sudo certbot renew --dry-run
Certbot Mode Comparison
Mode | Port Requirements | Web Server Needed | Best Use Case | Renewal Complexity |
---|---|---|---|---|
Standalone | 80 (must be free) | No | Fresh servers, testing | Medium (needs hooks) |
Webroot | 80 (can be occupied) | Yes | Production with existing server | Low |
Apache plugin | 80 (can be occupied) | Apache only | Apache deployments | Very Low |
Nginx plugin | 80 (can be occupied) | Nginx only | Nginx deployments | Very Low |
DNS challenge | None | No | Behind firewalls, wildcards | Medium |
Real-World Use Cases and Examples
Scenario 1: API Server Setup
You’re deploying a Node.js API server and need SSL before configuring your reverse proxy:
# Get certificate first
sudo certbot certonly --standalone -d api.yourcompany.com
# Then configure your Nginx reverse proxy with the cert paths
# /etc/letsencrypt/live/api.yourcompany.com/fullchain.pem
# /etc/letsencrypt/live/api.yourcompany.com/privkey.pem
Scenario 2: Docker Container SSL
Running applications in Docker containers but want SSL certificates on the host:
# Stop containers using port 80
docker stop nginx-container
# Get certificate
sudo certbot certonly --standalone -d app.example.com
# Mount certificate directory into container
docker run -v /etc/letsencrypt:/etc/letsencrypt:ro your-app
Scenario 3: Multi-domain Development Environment
Setting up SSL for multiple development domains:
sudo certbot certonly --standalone \
-d dev1.yourcompany.com \
-d dev2.yourcompany.com \
-d staging.yourcompany.com
Security Considerations and Best Practices
Here are the key security practices to keep in mind:
- File Permissions: Let’s Encrypt sets secure permissions by default, but double-check that
privkey.pem
is only readable by root (600) - Backup Strategy: Back up
/etc/letsencrypt/
regularly, especially before server migrations - Rate Limits: Let’s Encrypt has rate limits (50 certificates per domain per week). Use staging environment for testing
- Key Rotation: While automatic renewal handles this, monitor renewal logs for failures
Use the staging environment when testing:
sudo certbot certonly --standalone --staging -d test.yourdomain.com
For production-ready deployments on reliable infrastructure, consider managed VPS solutions that can handle the networking requirements smoothly, or dedicated servers for high-traffic applications requiring guaranteed resources.
Troubleshooting Common Problems
DNS propagation issues:
If you’re getting validation failures, check DNS propagation:
dig yourdomain.com
nslookup yourdomain.com
Firewall blocking connections:
# Check if port 80 is accessible
sudo ufw status
sudo ufw allow 80/tcp
Permission errors:
Always run Certbot with sudo. If you’re getting permission denied errors:
sudo chown -R root:root /etc/letsencrypt/
sudo chmod -R 600 /etc/letsencrypt/archive/
sudo chmod -R 644 /etc/letsencrypt/live/
Certificate validation failures:
Check Certbot logs for detailed error information:
sudo tail -f /var/log/letsencrypt/letsencrypt.log
The standalone mode approach gives you clean separation between certificate management and web server configuration, making it easier to troubleshoot issues and maintain your SSL setup. Just remember to plan for the port 80 requirement and set up proper renewal automation, and you’ll have a rock-solid certificate management system.
For more detailed information, check out the official Certbot documentation and Let’s Encrypt documentation.

This article incorporates information and material from various online sources. We acknowledge and appreciate the work of all original authors, publishers, and websites. While every effort has been made to appropriately credit the source material, any unintentional oversight or omission does not constitute a copyright infringement. All trademarks, logos, and images mentioned are the property of their respective owners. If you believe that any content used in this article infringes upon your copyright, please contact us immediately for review and prompt action.
This article is intended for informational and educational purposes only and does not infringe on the rights of the copyright owners. If any copyrighted material has been used without proper credit or in violation of copyright laws, it is unintentional and we will rectify it promptly upon notification. Please note that the republishing, redistribution, or reproduction of part or all of the contents in any form is prohibited without express written permission from the author and website owner. For permissions or further inquiries, please contact us.