Report this

What is the reason for this report?

PHP Fatal error: Uncaught mysqli_sql_exception: Connection timed out

Posted on December 12, 2024

I’m connecting to my droplet fine on localhost, which proves that the IP, port, user and pw are correct, but when I load the same php code to a server that is supposed to connect to my DO database, I get:

PHP Fatal error: Uncaught mysqli_sql_exception: Connection timed out

Can anyone help me? this article doesn’t help becasue I can’t see the Control Panel (I have CLI) https://docs.digitalocean.com/products/databases/mysql/how-to/secure/#firewalls



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

If you are using a Managed MySQL database cluster there are a few things that you need to make sure that you have in place:

  • The Managed MySQL clusters do not use the default MySQL port, so you need to make sure that you are using 25060 as your port in your connection string
  • If you have enabled the trusted sources for your MySQL cluster, then you need to make sure that you also add your Droplet’s IP address to the allowed list so that the Droplet can connect to the MySQL cluster
  • If you have a firewall on your Droplet like UFW or a managed cloud firewall, make sure that you open port 25060 for outgoing TCP connections so that the Droplet can connect to the MySQL cluster

Let me know how it goes!

- Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.