Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[7.1.2] Multiple MySQL containers - connection issues (Connection refused)

Featured Replies

I'm trying to set up multiple MySQL Docker Containers. Problem is, I'm getting a "Connection refused" whenever I'm trying to connect to the MySQL Docker that I started after the first one.

It feels like there's an issue with ports, but that shouldn't be the case, as I'm using a custom network, not Bridge.

So here's a few details:

  • I use a custom network (br0) for these Docker Containers

  • The first MySQL container I start, works fine

  • Second MySQL container cannot be connected, and results in "Connection Refused"

  • I've tried to change the ports

  • Both MySQL Containers have separate AppData folders for data

  • I've tried to re-install the newer MySQL container several times. Always resulting in it working for a couple of seconds, and then returning to "Connection Refused"

  • I'm connecting with the Container name, instead of direct IP (tried the IP way as well however) - This shows the Container IP correctly when trying to connect

  • I've tried to change the permissions of the AppData folders, just to see if that makes any difference

  • Using the latest MySQL (also tried with 5.7)

  • UnRaid version is 7.1.2

I'm sure this is the wrong place to be asking about this, apologies for that, but as per usual with these things, I've been banging my head against the wall for the last 8 or so hours, and I'm about done ☠️

EDIT!

For the three of you who might have the same issue.. This was fixed by updating UnRaid to 7.1.4

EDIT2:

We're back at "Connection refused" after the weekend. Everything stated above still holds true :(

EDIT3: (This seems to be the fix)

ARP/MAC-level caching issue, and not a misconfiguration or database bug.

To fix this, I added a fixed IP address to the broken container, giving it enough distance between the rest of the containers (instead of having xxx.xxx.x.5 it's now xxx.xxx.x.250)

Edited by REllU
Added the answer to the original post, in case anyone ever has the same issue

  • Community Expert

7 hours ago, REllU said:

I'm trying to set up multiple MySQL Docker Containers. Problem is, I'm getting a "Connection refused" whenever I'm trying to connect to the MySQL Docker that I started after the first one.

It feels like there's an issue with ports, but that shouldn't be the case, as I'm using a custom network, not Bridge.

So here's a few details:

  • I use a custom network (br0) for these Docker Containers

  • The first MySQL container I start, works fine

  • Second MySQL container cannot be connected, and results in "Connection Refused"

  • I've tried to change the ports

  • Both MySQL Containers have separate AppData folders for data

  • I've tried to re-install the newer MySQL container several times. Always resulting in it working for a couple of seconds, and then returning to "Connection Refused"

  • I'm connecting with the Container name, instead of direct IP (tried the IP way as well however) - This shows the Container IP correctly when trying to connect

  • I've tried to change the permissions of the AppData folders, just to see if that makes any difference

  • Using the latest MySQL (also tried with 5.7)

  • UnRaid version is 7.1.2

I'm sure this is the wrong place to be asking about this, apologies for that, but as per usual with these things, I've been banging my head against the wall for the last 8 or so hours, and I'm about done ☠️


This is why I prefer to use MariaDB (Docker setting and easier to setup and make a sql instance wiht a sinlge user for a applicaiotn.... You are most likely fighting mysql allowed access networks and need to run MySQL database termainl commands to grant other netwroks and ip a username and password to the MySQL tables... Potentail port and dokcer network conflicts as well...

Heres a rundown Checklist for Running Multiple MySQL Containers on a Custom Network

Use a Custom Bridge or Macvlan Network (not bridge)!

If you're using br0, make sure:

  • It’s created correctly.

  • IPs aren’t conflicting.

  • Containers are properly assigned.

To create a Docker bridge network (if not done already):

Unraid Terminal Commands make a new docker bridge network called mynet

docker network create \

--driver bridge \

--subnet=172.25.0.0/24 \

mynet

Without some info and due to security... Here's an example...
https://forums.unraid.net/topic/188695-docker-network-issue/#findComment-1541042
(You would set theses in the unriad web UI docker template...) Default docker bridge is fine...

unriad terminal commands to run 2 mysql instances

# MySQL 1

docker run -d \

--name=mysql1 \

-e MYSQL_ROOT_PASSWORD=password \

-v /mnt/appdata/mysql1:/var/lib/mysql \

-p 3306:3306 \

--network=mynet \

mysql:latest

# MySQL 2

docker run -d \

--name=mysql2 \

-e MYSQL_ROOT_PASSWORD=password \

-v /mnt/appdata/mysql2:/var/lib/mysql \

-p 3307:3306 \ # <- different host port

--network=mynet \

mysql:latest


*So First Confirm you're not using -p 3306:3306 for both containers. That would cause "connection refused" for the second one due to port binding failure.

Like all dockers, check the logs. What does the log say... SQL database docker especially need time for first initialization...
After the MySQL Initialization Delay about 5 min....
Check logs...

docker logs -f mysql2

You would use the drop-down and click the mysql and click log options and look for:

"[Server] ready for connections."

Connecting by Container Name:

If both are on the same Docker network, container name DNS works:

mysql -h mysql2 -P 3306 -u root -p

*--If on a macvlan (br0) network, Docker container DNS won’t work. Use the container’s IP directly.

You can use a extra parm to set a container host name

These are all Optional!

--hostname redis.home.arpa --dns=192.168.2.1 --dns=8.8.8.8

*****Must use FQDN my search domin is home.arpa the container name is redis my FQDN is redis.home.arpa extra dns options if using tailscale to gurantee dns ip within a docker...

Double check on unraid permission and Puid and Guid Data Directory Permissions

Ensure the /mnt/appdata/mysql2 folder is owned by the right UID/GID:

docker safe permissions

chmod 777 -R *

chown nobody:users -R *

Otherwise its network database connection issues. You will need the sql docker runnign and console into it and conect to your sql with the root user at local host / 127.0.0.1

GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_user'@'%' IDENTIFIED BY 'your_password';

Replace:

  • your_database_name with the name of your database

  • your_user with the username

  • '%' allows access from any host (you can use 'localhost' or a specific IP)

  • your_password is the desired password

Then Flush sql privileges...
FLUSH PRIVILEGES;

example sql file...

If you want to give user appuser full access to a database called appdb, and allow remote access

CREATE DATABASE IF NOT EXISTS appdb;

CREATE USER IF NOT EXISTS 'appuser'@'%' IDENTIFIED BY 'supersecretpassword';

GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'%';

FLUSH PRIVILEGES;

  1. Use mysql -u root -p to log in as root before running these commands.

  2. For local-only access, change '%' to 'localhost'.or the ip of the network that will be access it (May be more then one the docker bridge network and the lan subnet...)

  3. For security, avoid using root for apps—create a dedicated user per app.

  • Author

@bmartino1 Thanks for the emotional support, and the help!

I managed to fix the issue. I'm not even going to go through all the steps I did to get here, but deep down, I felt like something was really off somewhere deep, because I couldn't find anyone who had same issues than I, and everyone who asked "how to run multiple instances of MySQL / MariaDB" were given an answer of "just rename it" basically.

Either way, as a last resort, I checked UnRaid's patch notes.

And long behold, there were updates about Docker and networking. Not strictly about the issues I had, but close enough.

So I made a backup, and updated to 7.1.4 and..

It now works :')

smiley.jpg

  • Author

After the weekend, the earlier behaviour had returned. Connection to the (now) MariaDB database worked once, and then stopped working completely, once again stating "Connection refused" when trying to connect with Adminer. The original installation of MySQL (that was installed for another Docker container to use) works fine.

Any help with this?

The odd part is, if I re-install MySQL / MariaDB, it always works once. But after that, the connection refuses, which feels like the ports are fighting each other, which shouldn't be possible when using a custom network?

EDIT:

The plot thickens. If I restart Adminer with a different IP, it'll connect to the MariaDB database just fine. Once. After that, it'll get locked out with "Connection refused"

So something allows a "new" app to connect to the database, but it'll somewhy get refused after it tries to connect again? :thinking:


EDIT2: (the solution. But why?)

This very clearly goes over my understanding, but I've (once again) seemingly fixed the issue.

While trying to figure this out, I (for some reason) wanted to try and bring in a third installation of MySQL into the mix. Just to see what would happen.

This installation worked just fine from the get go, and I was able to connect to the first and third installation through Adminer.

This is where I had to bring in ChatGPT to make any sense of the situation, and after quite a bit of back-and-forth, it asked me to change the IP address of the second (broken) installation to something completely different, while keeping the same subnet.

This worked, and it survived a full server restart. I asked ChatGPT as to why this is, and the answer it spit out was:

That’s the strongest confirmation yet that this was, in fact, an ARP/MAC-level caching issue, and not a misconfiguration or database bug.

Could someone smarter than me explain if this is the case, and how could I avoid this in the future? Will the change of the IP address fix this for me long term? (instead of .1-10 it's now .250)

Edited by REllU
More info on the issue

  • Community Expert

I would need a diag file form unraid to further assist.

This sounds like unraid docker misconfigurations. Potential docer network and port addigment issues.

"Any help with this?

The odd part is, if I re-install MySQL / MariaDB, it always works once. But after that, the connection refuses, which feels like the ports are fighting each other, which shouldn't be possible when using a custom network?

EDIT:

The plot thickens. If I restart Adminer with a different IP, it'll connect to the MariaDB database just fine. Once. After that, it'll get locked out with "Connection refused""

Even if a service is running a port lets say 3000 as its common. and I have 2 dockers that use port 3000 both are in a 2 separate bridge networks. That is still port conflict.
even more when 3000 is a range of ports for one service but a static web port for another docker. as docker, network nat puts both services at unarid IP:3000

I would need the output of docker network ls
and the docker network inspect

example of the defaults
docker network inspect br0

docker network inspect bridge

docker network inspect <custum name of made docker...>

with out this its hard to confirm and direct.

also review post:

  • Author

I was actually unaware that different networks conflict with each others' ports!
Appreciate the help btw, thank you.

docker network inspect br0

[
    {
        "Name": "br0",
        "Id": "3b46963ae1a3fea1cbc75b8b845d904730c98d7cd133c6dec35e71fc27b81f86",
        "Created": "2025-06-23T15:20:59.682209732+03:00",
        "Scope": "local",
        "Driver": "ipvlan",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "192.168.1.0/24",
                    "Gateway": "192.168.1.1",
                    "AuxiliaryAddresses": {
                        "server": "192.168.1.198"
                    }
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "18fb80f6b1e3307e4b181186987c95afc1f61f476daa0bd69036ccf61fd86ca9": {
                "Name": "GiteaSQL",
                "EndpointID": "cc55edf9dea1f0483ab1e36c1c55c6936699b4e1195d948587f7e3304bdddec7",
                "MacAddress": "",
                "IPv4Address": "192.168.1.250/24",
                "IPv6Address": ""
            },
            "268d078be482c4d8b1f393063a826c47faaa2489a0fec97380aad333b100a2fd": {
                "Name": "LeantimeSQL",
                "EndpointID": "7cf263ee21e2779f24f6ec4d5869cd0b96cf5e82d2f10b6a515da85fda7a4f0e",
                "MacAddress": "",
                "IPv4Address": "192.168.1.6/24",
                "IPv6Address": ""
            },
            "3f44a8664e40b363aae874512a18e3add7cbe2820e3a40df32d37dd82132367c": {
                "Name": "FileBrowser",
                "EndpointID": "367f7ab3143b3785bf767f82f9ed739799c0e74a588361a7d50119de0b204b64",
                "MacAddress": "",
                "IPv4Address": "192.168.1.5/24",
                "IPv6Address": ""
            },
            "523f2300e564cb373fb50a385077b5f11494f1177de144e0cae928e5019904b3": {
                "Name": "Gitea",
                "EndpointID": "2f34f6cb1cee700b036cea1aa05c1dd77c874749ab3b7795130faabc05df7977",
                "MacAddress": "",
                "IPv4Address": "192.168.1.251/24",
                "IPv6Address": ""
            },
            "6ae369e3b771aaa4d3f32f2f3babccb577dbf84e0ade689b2b041e95dc93a680": {
                "Name": "Rocket.Chat",
                "EndpointID": "b9b1e7406f35a660acdac22c69bc446dd194ced3984841a3535494213bd3b26c",
                "MacAddress": "",
                "IPv4Address": "192.168.1.4/24",
                "IPv6Address": ""
            },
            "8dbbe6d65a3660d79eca7e34abe53c328c248d50cdc4bd42a024d4cb654f14c1": {
                "Name": "leantime",
                "EndpointID": "a67f2ef552986bcfac4165789d0e9c7c0f3ae2ce9878bddb8407617ff9667655",
                "MacAddress": "",
                "IPv4Address": "192.168.1.7/24",
                "IPv6Address": ""
            },
            "b15e6d4f2f8acf09ef02537babd4f366c9564c34e8539e7fe77370e4dfe7f333": {
                "Name": "MongoDB",
                "EndpointID": "5d63d3c21a2816c34d033d78536cdf715d3f63cd659e7c6a9bfa53966cb23de2",
                "MacAddress": "",
                "IPv4Address": "192.168.1.3/24",
                "IPv6Address": ""
            },
            "b6b0ff486ce657c85193ad5cf7e07cb5cb7cf5426320a719ae4524090019e4a7": {
                "Name": "adminer",
                "EndpointID": "416dcece7e35b079dc6d2f4aab69625466231d1d32788b81d109a8b13556fa44",
                "MacAddress": "",
                "IPv4Address": "192.168.1.9/24",
                "IPv6Address": ""
            },
            "cefd02bd9de8ff9bb357671d8a70c1713a3deec44fe283be0a3149e49a289c4c": {
                "Name": "Nginx",
                "EndpointID": "dd8f7e2f4d5d14ad39ad627677a5306d9a49d36d3e2e1b7aaa07b637fe8baf23",
                "MacAddress": "",
                "IPv4Address": "192.168.1.2/24",
                "IPv6Address": ""
            }
        },
        "Options": {
            "parent": "br0"
        },
        "Labels": {}
    }
]

docker network inspect bridge

[
    {
        "Name": "bridge",
        "Id": "40c7dda0e142f389d8aaee05866e305c6903caba514df142c2186f9b9f1926f8",
        "Created": "2025-06-23T15:20:58.90293917+03:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "4d0ae86f2752deafd64df9d2ac8dd540b2ef7d25b895e2e1abb01844d5ee755f": {
                "Name": "unifi-controller",
                "EndpointID": "6a550dde15e968d3410c243ed0ea98e1ec523f27909c9df39ffc9f32ba8f4a98",
                "MacAddress": "02:42:ac:11:00:03",
                "IPv4Address": "172.17.0.3/16",
                "IPv6Address": ""
            },
            "a43140e66d055b33aad1a2a4db2e7c149f74fecca2a398ed028a676cd17b13b2": {
                "Name": "binhex-syncthing",
                "EndpointID": "ee1b090ea2314f1562786103137a07efbc4f80a72e0eddb5304c75b73f90f146",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            },
            "c4ade02fb0bba273c5aa2ed683dfd02508452dbf63cc762ae3cb0df9dc272d41": {
                "Name": "luckyBackup",
                "EndpointID": "166558bfda1e188a93d4dbcb17dd36fe283a95065bc47e44c6dc6b494d7092e8",
                "MacAddress": "02:42:ac:11:00:04",
                "IPv4Address": "172.17.0.4/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]

  • Community Expert

Thank you for sharing.

        "Containers": {
            "18fb80f6b1e3307e4b181186987c95afc1f61f476daa0bd69036ccf61fd86ca9": {
                "Name": "GiteaSQL",
                "EndpointID": "cc55edf9dea1f0483ab1e36c1c55c6936699b4e1195d948587f7e3304bdddec7",
                "MacAddress": "",
                "IPv4Address": "192.168.1.250/24",
                "IPv6Address": ""
            },
            "268d078be482c4d8b1f393063a826c47faaa2489a0fec97380aad333b100a2fd": {
                "Name": "LeantimeSQL",
                "EndpointID": "7cf263ee21e2779f24f6ec4d5869cd0b96cf5e82d2f10b6a515da85fda7a4f0e",
                "MacAddress": "",
                "IPv4Address": "192.168.1.6/24",
                "IPv6Address": ""

Appears to be your mysql instances. in which both sql instances are set to a static Ip on the lan and all ports should be accessible.

"Driver": "ipvlan", tells me the default unraid settings are using ipvlan thus each docker is using the same mac address. This could be causing communication issues.

I recommend stopping all dockers. going to docker settings and change ipvlan to macvlan and try again.

I also recomend upgradign to 7.1.4 due to some fixes to the unraid network

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.