I'm pretty new to LXD having recently discovered it. I'm making progress with the basic interactions with images and containers - it looks promising.

Currently I am stuck on a problem connecting from the host to a service running in a local container. This is my first time trying this. I get a "connection refused" error. More details below:

user@sparky1:~$ curl
curl: (7) Failed to connect to port 80: Connection refused

The host is Ubuntu Server 14.04 on my laptop - it's a new install and is pretty plain-vanila. I let the system do all of the configuration (including the lxcbr0 bridge) and haven't changed any of the out-of-the-box defaults.

I'm running a container based on a CentOSv6 image. The container is started and inside I am running a web server. From within the container I can connect to its local web server on port 80 just fine (by running "curl hostname"). It connects on the loopback IP I get a valid response from the local web server from within the container. Yay.

A successful response (even though it's a 403 reponse):

[root@wc1 ~]# curl wc1
<title>403 Forbidden</title>
<p>You don't have permission to access /
on this server.</p>
<address>IBM_HTTP_Server at wc1 Port 80</address>
[root@wc1 ~]#

If I try connecting via the IP on the bridge, either from within the container or from the host then I get the mentioned "connection refused" error.

So, I'm trying to figure out what it will take to allow connections from the host to the the web server running in the container. I have spent a few hours googling and have not found the answer (or been too dense to recognize it).

The firewall is disabled ("ufw status" says so). What am I missing? Thanks in advance.

  • I initially recalled I had specified the IP when issuing the 'curl' command from within the container, but in fact I had specified the hostname (which I noticed resolved to the loopback). This was the key to figuring things out – David MacBride Nov 5 '15 at 17:09

I solved my own problem. I initially recalled (assumed. sigh) that I had specified the IP when issuing the 'curl' command from within the container, but in fact I had specified the hostname. Once I noticed that I had in fact specified the hostname, and that the hostanme resolved to the loopback, i figured out my problem.

In my apache httpd.conf, the Listen di, which I hadn't notice resolved to the loopback device and not the IP on the lxcbr0 bridge. rective specified the hostname. The httpd.conf file was auto-generated by a vendor tool so I didn't think about it at first. Once I changed the Listen directive to listen on the correct IP ( everything worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.