Web container unable to connect to mysql container? (connection refused)

So I have a web container, and a SQL container that belongs to it. Yet, when I attempt to use the connection info of the sql container (including its own IP address) into the web container, I can’t seem to connect to it. Even if ip bind address is 0.0.0.0

Any idea how I can make this work? Firewall is disabled, so that’s not it.

Guess you should give some more details:

  • LXD or LXC

  • Version

  • OS
    etc.

  • Are both containers on one system/host?

  • What networks do you use?

  • What proxys (if any) do you use?

Yet, when I attempt to use the connection info of the sql container (including its own IP address) into the web container

What does that mean exactly?
You try to connect from the web container to the sql container or something else?

Do you get a specific error when connecting to (what I assume) is mysql ? or does it just hang ?

What does lsof -i show on the mysql containr

Is this a only listening on IPV4 issue ?

Indeed I should have been more detailed.

Using LXC 4.1, Ubuntu 18.04 minimal. Both containers are on the same system, default lxdbr0 name in bridged mode (eth0). And only using nginx proxy (which I still fail to properly set-up).

And it means that I’m trying to make WEB container (forums) to connect to the MYSQL container. But it appears that it cannot make the connection to the mysql container, as it seems to be rejecting it.

I have changed things and made the web/forum files into a single container so that’s sorted. But I’d still like to know how to make a remote connection to the sql container database from outside the container.

as it seems to be rejecting it.

Whats the erorr ?

From the looks of the logs, connection refused. While I can ping the containers just fine with each other. An example of another container with a php mysql remote application attempting to connect to the database container:

image

Not sure why it is refusing though. (even if I add 3306 at the end). SQL bind is set to 0.0.0.0, and its set locally on the same machine.

Can you show us where you changed this value? Did you restart MySQL so the change is enabled?

The error you get is Connection refused. This means that MySQL is not listening on all interfaces.

Instead of using an IP address, use the proper hostname, such as mysql.lxd.

Last time I used the host name, it didn’t resolve so I switched to IP instead. I’ll see if I can use the host tomorrow. As for the value, I changed it in either /etc/mysql/my.cnf or mariadb.cnf / conf.

Currently in bed, so I don’t recall which one of the two it was. It was set to 127.0.0.1 before I changed it, and ya. I rebooted mysql.