Can't access docker compose ports from external machine on the same network

I recently started an ubuntu 22.04.1 LTS server and wanted to set up plex using docker compose. I started by following this guide: Docker Media Server Ubuntu 22.04 with 23 Awesome Apps | SHB However when I got up to the section with radarr I noticed that I can’t seem to connect to the website from a computer on the same network. I tried both using the host computers local ip and the public ip. Running

sudo docker ps -a

4d471a13e1a3 lscr.io/linuxserver/radarr:nightly “/init” About an hour ago Up About an hour
0.0.0.0:7878->7878/tcp, :::7878->7878/tcp radarr

so it looks like the docker port is listening for port 7878

running

sudo ufw status

To Action From


25565 ALLOW Anywhere
7878/tcp ALLOW Anywhere
7878 ALLOW Anywhere
22 ALLOW Anywhere
25565 (v6) ALLOW Anywhere (v6)
7878/tcp (v6) ALLOW Anywhere (v6)
7878 (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)

so it looks like it should be allowed from my external computer

I then ran:

sudo lsof -n | grep TCP | grep LISTEN

docker-pr 152779 152780 docker-pr root 4u IPv4 801480 0t0 TCP *:7878 (LISTEN)
docker-pr 152779 152781 docker-pr root 4u IPv4 801480 0t0 TCP *:7878 (LISTEN)
docker-pr 152779 152782 docker-pr root 4u IPv4 801480 0t0 TCP *:7878 (LISTEN)
docker-pr 152779 152783 docker-pr root 4u IPv4 801480 0t0 TCP *:7878 (LISTEN)
docker-pr 152779 152784 docker-pr root 4u IPv4 801480 0t0 TCP *:7878 (LISTEN)
docker-pr 152779 152785 docker-pr root 4u IPv4 801480 0t0 TCP *:7878 (LISTEN)
docker-pr 152779 152786 docker-pr root 4u IPv4 801480 0t0 TCP *:7878 (LISTEN)
docker-pr 152787 root 4u IPv6 801485 0t0 TCP *:7878 (LISTEN)
docker-pr 152787 152788 docker-pr root 4u IPv6 801485 0t0 TCP *:7878 (LISTEN)
docker-pr 152787 152789 docker-pr root 4u IPv6 801485 0t0 TCP *:7878 (LISTEN)
docker-pr 152787 152790 docker-pr root 4u IPv6 801485 0t0 TCP *:7878 (LISTEN)
docker-pr 152787 152791 docker-pr root 4u IPv6 801485 0t0 TCP *:7878 (LISTEN)
docker-pr 152787 152792 docker-pr root 4u IPv6 801485 0t0 TCP *:7878 (LISTEN)
docker-pr 152787 152793 docker-pr root 4u IPv6 801485 0t0 TCP *:7878 (LISTEN)

I also ran

netstat -tln | grep 7878

tcp 0 0 0.0.0.0:7878 0.0.0.0:* LISTEN
tcp6 0 0 :::7878 :::* LISTEN

so I can’t figure out why my external computer on my network can’t connect. When I try curling from my host machine it works, both using localhost and the local ip, but not the public ip

THIS IS FROM THE HOST MACHINE:

curl localhost:7878
<!doctype html>Radarr.root {
overflow: hidden;
height: 100%; /* needed for proper layout */
}

  @media only screen and (max-width: 768px) {
    .root {
      display: flex;
      flex-direction: column;
      min-height: 100%;
      height: auto;
    }
  }</style><script defer="defer" src="/vendors.js?h=dPspGxSjngeC99722Fjl3w"></script><script defer="defer" src="/index.js?h=LpIAZrRLe8uNDiTtqSyeqQ"></script><link href="/Content/styles.css?h=+SnBcJ1jjOYb/a3qn19DyQ" rel="stylesheet"></head><body><div id="portal-root"></div><div id="root" class="root"></div></body><script src="/initialize.js"></script></html>

THIS IS FROM THE HOST MACHINE:

curl 192.168.1.234:7878
<!doctype html>Radarr.root {
overflow: hidden;
height: 100%; /* needed for proper layout */
}

  @media only screen and (max-width: 768px) {
    .root {
      display: flex;
      flex-direction: column;
      min-height: 100%;
      height: auto;
    }
  }</style><script defer="defer" src="/vendors.js?h=dPspGxSjngeC99722Fjl3w"></script><script defer="defer" src="/index.js?h=LpIAZrRLe8uNDiTtqSyeqQ"></script><link href="/Content/styles.css?h=+SnBcJ1jjOYb/a3qn19DyQ" rel="stylesheet"></head><body><div id="portal-root"></div><div id="root" class="root"></div></body><script src="/initialize.js"></script></html>

THIS IS FROM THE CLIENT (EXTERNAL) MACHINE:

curl 192.168.1.234:7878
curl : Unable to connect to the remote server
At line:1 char:1

  • curl 192.168.1.234:7878
  •   + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
     eption
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    

What is extra odd is that I am able to connect to the host server over port 22 for ssh from an external client machine, and I am able to connect over port 25565 for a minecraft server I’m running. Because of that I think it might be a docker issue. Any ideas?

If you’re facing issues accessing Docker Compose ports from an external machine on the same network, it’s important to consider several key factors. First, ensure that your Docker Compose configuration is set up correctly for port binding. The ports should be bound to the host correctly in the docker-compose.yml file using the format host_port:container_port. Next, check the firewall settings on the host machine. It’s possible that the firewall is blocking incoming connections on the ports you’re trying to access. Adjust the firewall settings to allow traffic on those ports. Additionally, verify that your network configuration allows communication between the machines on the specified ports. Sometimes, network policies or router settings can restrict traffic, preventing access to the services running in Docker. Finally, confirm that the services within your Docker containers are configured to listen on the correct interfaces and ports. They should be set to listen on all interfaces (0.0.0.0) or the specific external interface, not just localhost (127.0.0.1), to be accessible from external machines.

Interesting to see how new user accounts are created, only to post an generic answer, that sound like pure ChatGPT.

Please explain what Docker Compose ports are. To my knowledge there is no such thing. It would imply that Docker Compose has a listening backend process, which is not the case.

I am not sure how you come to this conclusion, after sharing your results that acknowledges the container can be accessed from the docker host itself by using the published port via localhost and the host ip. Network-wise, this is where docker’s involvement ends.

Have you tried to temporarily disable the firewall to check whether the firewall rules are incomplete?

The error message of the external host indicates it’s a Windows machine with a Powershell terminal. Please try this in a Powershell terminal: Invoke-WebRequest -URI "http://192.168.1.234:7878"