Multicontainer Public URL Socket Hang Up

Hi, I’m trying to expose a web server in a container. I can see from logs that the server (express) is successfully listening on port 80, but when I try to access it via the Public URL from the dashboard, I keep getting the ‘Error accessing device’ page with reason ‘socket hang up’.

I have tried the following in the docker-compose.yml but all have the same result

services:
  server:
    build: ./server
    expose:
      - "80"
    network_mode: host
services:
  server:
    build: ./server
    ports:
      - "80:80"
    network_mode: host
services:
  server:
    build: ./server
    ports:
      - "80:80"
    expose:
      - "80"
    network_mode: host

plus the above without network_mode, and with only network_mode: host without expose or ports set.

What needs to be in docker-compose.yml to be able to successfully reach the server?

Hi there, what output do you get when you console to your container and host and execute:

curl localhost -v

Host:

curl localhost -v
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.64.1
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
* Closing connection 0

Container:

curl localhost -v
* Expire in 0 ms for 6 (transfer 0x2248728)
* Expire in 1 ms for 1 (transfer 0x2248728)
* Expire in 0 ms for 1 (transfer 0x2248728)
* Expire in 2 ms for 1 (transfer 0x2248728)
* Expire in 0 ms for 1 (transfer 0x2248728)
* Expire in 0 ms for 1 (transfer 0x2248728)
* Expire in 2 ms for 1 (transfer 0x2248728)
* Expire in 0 ms for 1 (transfer 0x2248728)
* Expire in 0 ms for 1 (transfer 0x2248728)
* Expire in 2 ms for 1 (transfer 0x2248728)
* Expire in 0 ms for 1 (transfer 0x2248728)
* Expire in 0 ms for 1 (transfer 0x2248728)
* Expire in 2 ms for 1 (transfer 0x2248728)
* Expire in 0 ms for 1 (transfer 0x2248728)
* Expire in 0 ms for 1 (transfer 0x2248728)
* Expire in 2 ms for 1 (transfer 0x2248728)
* Expire in 0 ms for 1 (transfer 0x2248728)
* Expire in 1 ms for 1 (transfer 0x2248728)
* Expire in 2 ms for 1 (transfer 0x2248728)
* Expire in 1 ms for 1 (transfer 0x2248728)
* Expire in 1 ms for 1 (transfer 0x2248728)
* Expire in 4 ms for 1 (transfer 0x2248728)
* Expire in 1 ms for 1 (transfer 0x2248728)
* Expire in 1 ms for 1 (transfer 0x2248728)
* Expire in 2 ms for 1 (transfer 0x2248728)
*   Trying ::1...
* TCP_NODELAY set
* Expire in 149997 ms for 3 (transfer 0x2248728)
* Expire in 200 ms for 4 (transfer 0x2248728)
* Connected to localhost (::1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.64.0
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server

Looks like your application isn’t returning a valid HTTP response on port 80, which is why you are seeing the message from the public URL proxy.

My bad, I was creating a https server. :roll_eyes:

No worries. Hopefully changing your app to listen on HTTP/80 will solve this issue.

I was using https.createServer in node instead of http.createServer
All good now.