Discourse rebuild fails with port 443 in use

AI-generated summary

A user 11145 reports that Discourse fails to rebuild due to port 443 being in use, with error logs indicating a bind conflict. The issue appears tied to Let’s Encrypt certificate expiration warnings and an external nginx server running on the host. Falco advises checking active processes via netstat -tulpn | grep 443, which reveals nginx occupying port 443. 11145 removes nginx per Falco’s suggestion, but Discourse still fails to start. Falco clarifies that if Discourse was intentionally set up behind an external nginx reverse proxy (as in the user’s app.yml), removing nginx breaks the setup — and Let’s Encrypt inside Docker cannot work with an external proxy. 11145 resolves the issue by reverting the port mapping in app.yml to - "25654:80" and avoiding nginx removal. Another user, littleviolette, confirms similar issues after following a DigitalOcean guide to install Discourse behind nginx, asking for guidance on safely reversing the setup. Key takeaways: do not remove external nginx if it’s intentionally configured; use external SSL certs if behind a reverse proxy; and avoid exposing SMTP credentials in public pastebins as noted by Falco.

Yesterday discourse stopped working, when you try to run the command

/var/discourse# ./launcher rebuild app is an error.

Error response from daemon: driver failed programming external connectivity on endpoint app (fc5fe43d9a3baadebc8c50fe62b740c08a65fe197697f6fb10e010541e390474): Error starting userland proxy: listen tcp 0.0.0.0:443: bind: address already in use.

http://pastebin.com/TB8gzv5p

My app.yml
http://pastebin.com/WNp5tMk7

When trying to enter the site, I get the error “SEC_ERROR_EXPIRED_CERTIFICATE”

Is it related to Let’s Encrypt issues?

Yes, Let’s Encrypt said that the certificate is completed

Your certificate (or certificates) for the names listed below will expire in 9 days (on 29 Nov 16 04:54 +0000). Please make sure to renew your certificate before then, or visitors to your website will encounter errors.

I tried to update the team
root@user:/var/discourse# rm -rf /var/discourse/shared/standalone/ssl
root@user:/var/discourse# rm -rf /var/discourse/shared/standalone/letsencrypt
root@user:/var/discourse# ./launcher rebuild app

I tried to update it with the command
But it didn’t help(

You have something using the 443 port on the host. Please remove it and try again.

netstat -tulpn | grep 443

Here’s the result

How can I remove it?

sudo apt remove nginx

Why did you install nginx on the host? If you installed it by accident it may be safe to remove.

Now here’s a line, but the site is not working.

Did you rebuild after removing outside nginx?

First I removed nginx, then this command /var/discourse# ./launcher rebuild app
discourse and not working(

First, like I said:

If you installed it by accident it may be safe to remove.

Looking again trough your pastebin:

  1. Your SMTP user & password is there, please remove

  2. You were setting Discourse to a higher port, so you were using nginx to host anything else right? So you shouldn’t remove the outside nginx

  3. IF you are running a reverse proxy outside the docker container, you can’t use the Let’s Encrypt template inside the docker container. You must get SSL in another way.

Thank You))) Understood))
After removing Nginx
in the yml file changed - “25654:80” # http 80:80

@Falco I have been having issues with port 443 and Let’s Encrypt as well probably due to the fact that I unintentionally installed Discourse behind nginx following the instruction here.

Is there a way to safely reverse this process? Sorry I am not a professional programmer. :confused: