Issue connecting to MySQL server hosted in Docker container

Hi everyone,

I’m having trouble connecting to my MySQL server, which is running in a Docker container. I’m 100% sure of the details of my setup, host name, DB, user, password. Yet no luck. I get hits error: Couldn’t connect with these settings

Retry

connect ECONNREFUSED 127.0.0.1:3306

I’ve verified the following:

  1. The MySQL server is running in the Docker container.
  2. The bind_address is set to *.
  3. I can connect to the MySQL server using the command line from within the Docker container.
  4. The user root has access from both localhost and %.

Despite this, I cannot connect to the MySQL server from n8n. I’ve double-checked the connection settings, but it still fails.

Any suggestions or troubleshooting steps would be greatly appreciated!

Thanks in advance!

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @Mahmood_Alabbas,

Welcome to the community :cake:

We see this a lot, If you are also running n8n in Docker trying to access 127.0.0.1 accesses the local host which would be the n8n container which wouldn’t have MySQL installed.

Can you try using either the Docker loopback address which could be something like 172.17.0.1 depending on configuration or try using the IP for the MySQL container and see if that helps.

I have the same exact problem when i was trying to connect n8n web app to mysql running in docker container.