0

On my host Ubuntu 18.04 I am running two lxc containers using default setups. Containers use Ubuntu 18.04 as well. I have an app running on container1 that offers an https based service on https://localhost:3000/. Container2 is not able to even establish a connection with container1.

Container2 can ping container1 and read the html of the default Apache2 server running on localhost (for container1). Testing with netcat, I can establish connection with a few main ports, however I get connection refused for port 3000.

root@c2:~# nc -zv c1 22
Connection to c1 22 port [tcp/ssh] succeeded!
root@c2:~# nc -zv c1 80
Connection to c1 80 port [tcp/http] succeeded!
root@c2:~# nc -zv c1 443
nc: connect to c1 port 443 (tcp) failed: Connection refused
nc: connect to c1 port 443 (tcp) failed: Connection refused
root@c2:~# nc -zv c1 3000
nc: connect to c1 port 3000 (tcp) failed: Connection refused
nc: connect to c1 port 3000 (tcp) failed: Connection refused

The same situation applies between my host and any of my containers. Only ports 22 and 80 seem to be reachable by default. I tried enabling ufw on all containers, but it still doesnt work out:

root@c1:~# ufw status
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
22/tcp                     ALLOW       Anywhere                  
22                         ALLOW       Anywhere                  
443                        ALLOW       Anywhere                  
873                        ALLOW       Anywhere                  
3000                       ALLOW       Anywhere                  
Anywhere on eth0@if16      ALLOW       Anywhere                  
Apache                     ALLOW       Anywhere                  
80                         ALLOW       Anywhere                  
20                         ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
22/tcp (v6)                ALLOW       Anywhere (v6)             
22 (v6)                    ALLOW       Anywhere (v6)             
443 (v6)                   ALLOW       Anywhere (v6)             
873 (v6)                   ALLOW       Anywhere (v6)             
3000 (v6)                  ALLOW       Anywhere (v6)             
Anywhere (v6) on eth0@if16 ALLOW       Anywhere (v6)             
Apache (v6)                ALLOW       Anywhere (v6)             
80 (v6)                    ALLOW       Anywhere (v6)             
20 (v6)                    ALLOW       Anywhere (v6)             

Anywhere                   ALLOW OUT   Anywhere on eth0@if16     
Anywhere (v6)              ALLOW OUT   Anywhere (v6) on eth0@if16

Even testing via curl clearly shows me that port connection is closed and thats the issue:

root@c2:~# curl https://10.155.120.175:3000/
curl: (7) Failed to connect to 10.155.120.175 port 3000: Connection refused

I have been stuck in this issue for a week, can anyone help me troubleshoot this?

Edit (additional data):

results for netstat on container1:

root@c1:~# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      289/systemd-resolve 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1385/sshd           
tcp        0      0 127.0.0.1:3000          0.0.0.0:*               LISTEN      293/MyApp           
tcp6       0      0 :::80                   :::*                    LISTEN      310/apache2         
tcp6       0      0 :::22                   :::*                    LISTEN      1385/sshd  
2
  • On container1, what is the output of netstat -lntp?
    – eftshift0
    Nov 19, 2021 at 12:57
  • hello @eftshift0 the output was edited into the post.
    – Mnemosyne
    Nov 19, 2021 at 13:04

1 Answer 1

1

Port 3000 is only listening for localhost. You need to configure your application correctly so that the port is open to 0.0.0.0 (as you can see in other ports).

2
  • Thank you! You were right the connection is now established.
    – Mnemosyne
    Nov 19, 2021 at 14:07
  • 1
    Hey, one (as in "I") can be lucky once in a while :-D
    – eftshift0
    Nov 19, 2021 at 14:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .