Error starting userland proxy: listen tcp4 0.0.0.0:443: bind: address already in use

Hello

My domain is:

I ran this command:

when I started docker I received a message:

  • docker compose -f docker-compose.prod.yml up
  • Error response from daemon: driver failed programming external connectivity on endpoint nginx (e0ee73bf9b8a7b6f1dc9da0e111cdb10a2088f9597ff30bd72334d9607fc1ce9): Error starting userland proxy: listen tcp4 0.0.0.0:443: bind: address already in use

Then I checked who is listening on port 443

  • sudo lsof -i -P -n | grep 443

Got a reply

  • nginx 29804 root 8u IPv6 278268 0t0 TCP *:443 (LISTEN)
  • nginx 29804 root 9u IPv4 278269 0t0 TCP *:443 (LISTEN)
  • nginx 29805 www-data 8u IPv6 278268 0t0 TCP *:443 (LISTEN)
  • nginx 29805 www-data 9u IPv4 278269 0t0 TCP *:443 (LISTEN)

and the main page of the site gives

  • Welcome to nginx!
  • If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

The site becomes accessible along the path from the config
/etc/nginx/sites-enabled/*;
with basic settings, if I replace them with my own, the site becomes inaccessible

And I must give from mine
/etc/nginx/conf.d/*.conf;

It produced this output:

My web server is (include version):

  • nginx version: nginx/1.18.0 (Ubuntu)

The operating system my web server runs on is (include version):

  • Ubuntu 22.04 (LTS) x64

My hosting provider, if applicable, is:

  • digitalocean

I can login to a root shell on my machine (yes or no, or I don't know):

  • yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel):
*no

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot):

  • certbot 1.21.0

How can I solve this problem?

I think this means the host you are running docker on already has something on port 443 (e.g. a web server) so docker can't bind to that for your container services.

[Your question is perhaps better suited to stackoverflow, at least to get the answers you need, it's not yet anything to do with Let's Encrypt]

2 Likes

You can't run two services on the same port. If it's a freshly installed server and you are NOT using or planing to use nginx for anything (it came preinstalled?), you can just uninstall it. If you ARE using nginx for something else, then you probably can install the other service on a different port and configure nginx as a reverse proxy for it.

1 Like

I want to use port 443 for docker,
how to remove unnecessary nginx?

sudo apt remove nginx

or you can just stop it for now, if you are not absolutely certain you don't need it.
sudo service nginx stop

1 Like

After I stopped nginx
gives the following message when trying to restart docker with command:

docker compose -f docker-compose.prod.yml up --build

nginx | 2024/02/15 11:34:31 [emerg] 1#1: cannot load certificate "/etc/letsencrypt/live/rentyon.com/fullchain.pem": BIO_new_file() failed (SSL: error:02001002:system library :fopen:No such file or directory:fopen('/etc/letsencrypt/live/rentyon.com/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)

and command

sudo lsof -i -P -n | grep 443

doesn't show anything

This means nginx is looking for the certificate file and can't find it. I'm not an nginx expert but I'd suggest removing the https configuration (the listen on port 443 and pointers to the certificate files) then try it all again.

Alternatively if you're not an nginx expert either, try out Caddy (caddyserver.com) instead as it has automatic https.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.