Localhost is not a valid ip address

I have set up a container with Tomcat8 and nginx to serve up website access for my home lab. When I try to pass the host system’s network connection through to the container I receive an error message about localhost not being a valid ip address. I use lxc config device add ... listen=tcp ... connect=tcp:localhost:443 to pass the connection through. I’ve used it with success in the past, including the weekend of May 11-12.

This occurred when the host had (vanilla) Ubuntu 18.04 installed, and when it had Ubuntu 18.10. LXD was installed using snap.

I would appreciate help with sorting this matter out.

~ML

@eunosm3 are you using the proxy device?

If so then you need to specify only numeric IP addresses, rather than “localhost”.

So try tcp:127.0.0.1:443 instead

Thanks
Tom

Have a look at

If you have existing containers that mention localhost, then also see the workaround in the post.

Tom,

Thanks for the response. Using localhost had worked previously, but I did try using the numeric IP already. It seemed to work, but I still couldn’t connect. Based on simos’ response (abt an hour after yours), something changed (?had been deprecated, now has been removed?) with LXD.

Thank you, too, for your response. I’ll attempt the workaround over the weekend. The linked question seems to reflect the problem I am having, so I’m hopeful it will work.

Yes support for localhost was removed due to potential security issue as it depended on resolver libraries in the container.

Your suggested solution solved the problem. Thank you for the guidance.

Tom
Just curious where I can find out anout or be notified of CLI changes like this one. I had people with existing systems that used “localhost” then I’m guessing SNAP LXD updated and then it broke for them.

Thanks for any guidance
Brian

It’s not a CLI change, it was missing server side validation which then got added following some very odd bug reports due to people using names instead of addresses.

This appeared as:

lxd/proxy: Validate the addresses

In the LXD 3.13 list of bugfixes and as we only ever had one report of someone doing this and having issues at the time, it didn’t seem to warrant being highlighted (also because the documentation always referred to address and ports for this config key).

Thanks Stephane !