Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Certbot "Could not bind TCP port 80 because it is already in use by another process on this system"

Technical article
Hosting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

Certbot prints Could not bind TCP port 80 because it is already in use by another process on this system (such as a web server). Please stop the program in question and then try again. when the standalone method tries to start its own small web server on port 80 and another program already holds that port. The holder can be the site's own web server. Either move the certificate to the webroot method, so Certbot uses the running web server, or free port 80 for the length of each run.

What the error means

The standalone method does not use your web server. The Certbot documentation says it "needs to bind to port 80 in order to perform domain validation, so you may need to stop your existing webserver", and that it does not rely on any other server software on the machine.

In the Certbot 5.10.0 source, when binding fails with the address-in-use error code (errno.EADDRINUSE), Certbot builds the message above and asks the user a yes or no question with the choices "Retry" and "Cancel", with Cancel as the default. If the answer is not Retry, the command stops with that message. Our own reading: a run from a scheduled job has nobody to answer, so it stops at once with the message.

The same source has a sibling message for a permission fault: Could not bind TCP port 80 because you don't have the appropriate permissions (for example, you aren't running this program as root). That is not a port conflict.

The documentation also says that by default Certbot first tries to bind the port for all interfaces over IPv6 and then over IPv4, and continues as long as at least one bind succeeds. It adds that on most Linux systems IPv4 traffic is routed to the bound IPv6 port, so "the failure during the second bind is expected". Our own reading: a failure of the second bind on its own is therefore not the fault. The message above is raised when the bind fails with the address-in-use error code and the question is answered Cancel, or cannot be answered.

Likely causes

Cause What you see How to confirm
The site's web server is running on port 80 The message at every run while the site is up ss lists nginx or Apache on port 80
Another service holds port 80 A proxy, load balancer or container publisher listed instead The process name in the ss output
A systemd socket unit holds the port Port 80 is listening although the service is stopped systemctl list-sockets lists a unit for port 80
An earlier Certbot run is still running Two Certbot processes listed ss lists a process named Certbot or Python
The certificate was made when no web server ran, and a web server was installed later The first issue worked, the first renewal fails The renewal file says authenticator = standalone

Prove the cause before changing anything

All of these steps only read.

1. Find who holds port 80. The ss manual describes -l as showing only listening sockets, -t as TCP sockets, -n as no service name lookup, and -p as showing the processes using sockets. Run it as an administrator.

ss -ltnp '( sport = :80 )'

A listed nginx, Apache or proxy is the holder. A line for the web server confirms the table's first row. No line means the port is free now and the fault was brief or came from another run.

2. Check for a socket unit. The systemd manual describes list-sockets as listing "socket units currently in memory, ordered by listening address".

systemctl list-sockets

3. Read which method the certificate uses. The Certbot page shows a renewal file with the line authenticator = standalone, under /etc/letsencrypt/renewal/. Read the file for your certificate name. Our own reading: if it says webroot, nginx or apache, the message does not come from this certificate.

4. List the certificate names. The page shows that this command lists each certificate name and its domains.

certbot certificates

Fix

Choose the route that matches your site.

Keep the web server running: change the method to webroot

The Certbot documentation says the webroot plugin is for a local web server whose content you can change when you "prefer not to stop the webserver during the certificate issuance process". The web server must serve files from /.well-known/acme-challenge out of the webroot folder. If it does not, see Certbot "Some challenges have failed.": Type: unauthorized, "Invalid response" and 404.

The reconfigure command is documented for Certbot 2.3.0 and newer. In the 5.10.0 source, its description says it sets new options for an existing certificate "without forcing renewal", and can be used for "authenticator, installer, and hooks". The Certbot page documents the --authenticator option and the --webroot-path option. The reconfigure command does a dry run first and saves only on success, according to the page.

First save the current state. The GNU manual says "cp copies files (or, optionally, directories)." Copy the renewal file for the certificate:

cp -p /etc/letsencrypt/renewal/example.com.conf /root/example.com.conf.2026-12-04

Risk: the next command changes the saved renewal options for this certificate, so every later renewal uses the new method. If the web server does not serve the challenge path, later renewals fail with a different message.

Replace the certificate name and the webroot path with yours.

certbot reconfigure --cert-name example.com --authenticator webroot --webroot-path /var/www/example

Risk: copying the saved renewal file back over the changed one returns the method to standalone, and the port conflict returns with it.

Only if you need to back out: copy the saved renewal file back over the changed one.

cp -p /root/example.com.conf.2026-12-04 /etc/letsencrypt/renewal/example.com.conf

Keep standalone: stop the web server around each renewal

The Certbot documentation gives this example for a single certificate obtained with standalone: use --pre-hook and --post-hook on certbot renew so the web server stops before renewal and starts after it. The documentation says hooks run only if a certificate is due for renewal, and that a failing hook does not stop renewal from being attempted. The site is off during each run. Our own advice: choose this only for a site that can be off for a minute, and note that the stop and start commands depend on how your web server is installed.

This route is not only for one run. The same page says that options given to certbot renew "will apply to every certificate for which renewal is attempted" and that "If a certificate is successfully renewed using specified options, those options will be saved and used for future renewals of that certificate". Its example renewal file has a post_hook line, so hooks are among the saved options. When a certificate is due and renews with this command, its stop and start hooks are written into its renewal file and run at every later renewal of it, scheduled ones included. If no certificate is due, nothing runs and nothing is saved. The command below names one certificate with --cert-name, a form the page also uses with certbot renew, so that only that certificate's renewal file changes.

First save the current state. Write down whether nginx is running and the time, then copy the renewal file the command can change:

cp -p /etc/letsencrypt/renewal/example.com.conf /root/example.com.conf.2026-12-04

Disruptive step: the next command renews the named certificate if it is due and stops nginx for the length of that run, so the site is off until the post-hook starts it again. If the renewal succeeds, it also saves the stop and start hooks in that certificate's renewal file, so they run at every later renewal. A stop cannot be undone by the command itself. Only the start command in the back-out brings the site back, and only the restored renewal file removes the saved hooks.

The page's example uses nginx and the service command. Replace both with your own web server's stop and start.

certbot renew --cert-name example.com --pre-hook "service nginx stop" --post-hook "service nginx start"

Only if you need to back out, because the run ended and nginx is still stopped: start it with the page's own post-hook command.

service nginx start

Only if you need to back out the saved hooks: copy the saved renewal file back over the changed one.

Risk: the back-out command overwrites the renewal file with the copy made before the run. The saved hooks are gone, so the next scheduled renewal no longer stops and starts the web server, and the port conflict returns for a certificate that uses standalone. Any other change made to that renewal file since the copy is lost as well.

cp -p /root/example.com.conf.2026-12-04 /etc/letsencrypt/renewal/example.com.conf

The page describes a second way to get the same effect on every renewal: executable files placed in /etc/letsencrypt/renewal-hooks/pre and /etc/letsencrypt/renewal-hooks/post, which Certbot runs as pre and post hooks.

Keep standalone on another port

The --http-01-port option sets the port Certbot listens on. The page says it "only affects the port Certbot listens on", and that "A conforming ACME server will still attempt to connect on port 80". Our own reading: this helps only where something forwards port 80 to the port you choose.

Example (illustrative): on web01, nginx was installed after the certificate for example.com was issued with standalone. The first renewal prints Could not bind TCP port 80 because it is already in use by another process on this system (such as a web server). ss -ltnp '( sport = :80 )' lists nginx. The renewal file says authenticator = standalone. The administrator saves the file, runs certbot reconfigure --cert-name example.com --authenticator webroot --webroot-path /var/www/example, and the dry run inside the command succeeds.

Confirm the fix

  1. Run a dry run for the certificate.
certbot renew --cert-name example.com --dry-run
  1. The run ends without Could not bind TCP port 80. The Certbot page says --dry-run uses the Let's Encrypt staging server, so no live certificate is replaced.
  2. ss -ltnp '( sport = :80 )' still lists only the web server.
  3. The renewal file shows the new authenticator line.

What to watch afterwards

  • Run a dry run after installing or removing a web server, a proxy or a container platform on the host.
  • The Certbot page says certbot renew is designed for automated use and runs only when a certificate is near expiry, Our own reading: a conflict can therefore stay hidden for weeks. Watch the renewal output or its exit status.
  • Keep a note of which method each certificate uses.

Risks and limits

Sources