Hey everyone, I’m stuck trying to set up n8n for my Java project automation. I’ve got XAMPP and MySQL running on my computer, and n8n is installed too. But when I try to connect n8n to my local MySQL database, it’s not working.
I’m using these settings:
Host: 127.0.0.1
Port: 3306
User: root
Database: myproject
But I keep getting a ‘connect ETIMEDOUT’ error. It’s frustrating because I can connect to the database just fine using phpMyAdmin and MySQL Workbench.
I’ve already checked that:
XAMPP MySQL is definitely running
My firewall isn’t blocking port 3306
I’ve tried both ‘localhost’ and ‘127.0.0.1’ as the host
The login details work in other programs
Any ideas what could be causing this timeout? I’m out of ideas and could really use some help!
hey there, i had a similar issue. have u tried changing the host to ‘mysql’ instead of 127.0.0.1? sometimes n8n needs the docker network name. also, double-check ur n8n container’s network settings. make sure its on the same network as ur xampp setup. hope this helps!
I’ve encountered this problem before when setting up n8n with local databases. One thing that often gets overlooked is the MySQL bind-address configuration. By default, it’s usually set to 127.0.0.1, which can cause connection issues.
Try editing your my.ini file (usually found in the MySQL folder of your XAMPP installation) and look for the bind-address line. Change it to 0.0.0.0 to allow connections from any IP. Don’t forget to restart your MySQL service after making this change.
Also, ensure that your n8n instance has the necessary MySQL drivers installed. Sometimes, connection timeouts can occur if the proper drivers are missing. You might need to install the mysql2 package if you haven’t already.
If these steps don’t resolve the issue, you could try creating a specific user for n8n with appropriate privileges, rather than using the root account. This can sometimes help bypass certain connection restrictions.
Have you considered using SSH tunneling? This can sometimes bypass connection issues when working with local databases. Set up an SSH tunnel from your n8n server to your local machine, then configure n8n to connect to ‘localhost’ through this tunnel. It’s a bit more complex, but it’s solved similar problems for me in the past.
Another thing to check: Make sure your MySQL user account permissions allow connections from ‘%’ (any host), not just ‘localhost’. You can modify this in the MySQL user privileges.
If all else fails, you might want to try setting up a reverse proxy like Nginx. This can sometimes resolve connectivity issues between n8n and local services. It takes some setup, but it’s a robust solution for complex networking scenarios.