Error: Database connection failed It is possible that the database is overloaded or otherwise not running properly. The site administrator should also check that the database details have been correctly specified in config.php
What is the issue you’re encountering
Moodle cannot connect to MySQL database on Dreamhost for a website registered on Cloudflare.
What steps have you taken to resolve the issue?
I have the A records correct and they do terminate to the correct IP, but it says I am unable to connect to the database when I try and configure the Config.php file for Moodle. I want to start here to make sure I don’t need to have a specific setting to allow connection from Moodle to the database on Dreamhost through the mySql A record. I am able to connect to and login to the database when going directly to it on phpMyAdmin through the IP and the host.
What feature, service or problem is this related to?
Cloudflare can only proxy HTTP/HTTPS traffic (unless using Cloudflare Spectrum) so if your database connection is made to a proxied hostname, then it won’t work.
You’ll need to use an unproxied hostname, the IP address, localhost or some other method that doesn’t use a proxied DNS record to connect to your database.
Thanks for the response!
Would turning proxy off the DNS record here resolve that issue?
I forgot to mention I have done that for all the mySQL A records I have here.
Using localhost or the IP address for the dbhost still presents the same connection error.
Often the default hostname for the database is set to the hostname of the site, and when adding a site to Cloudflare this breaks the database connection when the record is proxied.
If the MySQL hostname is unproxied, you should be ok, however this…
…seems to indicate it’s not a Cloudflare issue since none of those requests would pass through Cloudflare.