Bind for 0.0.0.0:443 failed: port is already allocated

AI-generated summary

A user, Rs40x, encountered an issue during a Discourse upgrade where the rebuild failed, resulting in the forums being down. The error message “Bind for 0.0.0.0:443 failed: port is already allocated” indicated that the port was already in use. After trying a solution from GitHub, Rs40x found that the issue was due to attempting to upgrade the container while it was still running. The solution involved:

  • Updating the Docker container with apt-get update and apt-get dist-upgrade lxc-docker
  • Stopping the container with docker stop containerID
  • Running a manual upgrade of the Docker container with git pull and ./launcher rebuild app

Rs40x noted that the instructions on the UI only mentioned running the third step, which led to the issue.

Forums are down since rebuild failed during the upgrade (var/discourse/launcher rebuild app).

I tried the solution from here. The Following solution did not work.

systemctl stop docker
rm -rf /var/lib/docker/network/files
systemctl start docker

/usr/bin/docker: Error response from daemon: driver failed programming external connectivity on endpoint app (db53): **Bind for 0.0.0.0:443 failed: port is already allocated**.

# netstat -tulpen | grep 443
tcp6       0      0 :::443                  :::*                    LISTEN      0          488127     30700/docker-proxy  

# docker ps

1d8b7461b27d        local_discourse/import   "/sbin/boot"        6 weeks ago         Up 9 minutes        0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   import

What else can I do to get the forums back online?

Thanks in advance.

[Solution]

  1. Update the Docker Container
  2. Stop the Container
  3. Run rebuild

I missed step 1 and 2. Because the instructions on the UI said to only to run step 3 using the console.

  1. To update the Docker Container
apt-get update
apt-get dist-upgrade lxc-docker
  1. Stop the Docker Container
docker container ps
docker stop containerID
  1. Manual Upgrade of Docker Container
cd /var/discourse/
git pull
./launcher rebuild app

You may have to run the launcher twice.

Reason for Error “bind was already in use”>> Trying to upgrade the discourse while container is running.

I hope this helps someone.