MySQL Remote connection problem

I have been battling this for a little over 3 hours now. Enabling everything, increasing timeout limits, allowing world access to my server, and allowing remote IP connection. Still, trying direct connection over Node.js I still get the message

“Error connecting: connect ETIMEDOUT”

I made sure my site URL in project settings tallies with the database, I used the right syntax and tried it backward, etc.

I did everything, increased timeout as George instructed. Nothing worked. I even went to my backend and did multiple tweaking. I tried to connect with my IP, Domain Name, FTP, SSH, and everything out there, and some even unconventional.

I think this is worth looking into considering that a lot of topics exist on this subject and I have seen anyone that provides an actual resolution.

Oh, also let me mention that I searched every topic extensively on the subject in the community before I submitted this post.

Node.js direct database connection does not connect to the MYSQL server on WHM CPanel.

If I’m wrong, please share your step-by-step solution to connect and I will stand corrected.

OH! and when I exported my database to my Xamp localhost, I click connect and Bang! Database Connected, Instantly. Working on my localhost.

Have you added the IP you are using to connect to the Hosts file on WHM, then make sure to apply? You will probably need to do the same for the firewall, within the CSF configuration (if you are using CSF), also check ModSecurity logs if you have access as a rule may be triggered there... Which you may have to disable for the specific host...

Trust me Dave, in 3 hours. I have almost ruined my Dedicated server. I added the IP, restarted my remote server, my SQL server, almost reset my DNS, restarted DNS, restarted HTTP server (apache), removed node.js, included node.js and… (head down - sigh)

Can you connect using a tool such as Workbench?

Yes, I can connect via workbench. ALways I access it directly from wappler when Im working with PHP. However, with node.js is always a no.

If you can connect via Workbench then it suggests maybe ModSecurity is blocking the request. Have messaged you privately.

1 Like

Ok, im looking into MODSecurity. Also responded to PM

Isn’t ModSecurity an Apache module? How does it intercept a MySQL connection?

THE SOLUTION: @Dave gave me that worked is that he disabled CSF on my Apache server and it was instant. Thanks a lot, Dave. Much respect.

PHP runs on Apache. If the PHP executed is contained within a rule then ModSecurity will deny it, anyway ModSec is not the issue. Have pinpointed it.

Its temporary we can debug CSF tomorrow but for tonight PLEASE enable CSF. It is a great tool and does a great job!




I remembered what it is.

As WHM denies remote access to port 3306 you will need to remove this in the CSF ports configuration for denied ports (remote). If you have further issues try this. Also a good idea to change the default port for MySQL. Plenty of documentation and answers on how to do that on the WHM support site.

Further to the above.

The default configuration for CSF ports is fine for Wappler to communicate at the host level as is localhost to the hosted site, all good. But for remote connections you will need to do the above for using the Database Connector/Query Builder within Wappler…

Dave over and out! :slight_smile: