Intermittent "SQLSTATE[HY000] [2002] Connection refused" errors.

Hello,

So I’ve recently deployed a Laravel app and followed the documentation on setting up a MySQL app. That seems to be working as intended, I can ssh in and login to MySQL with the root user and confirmed my migrations all ran successfully.

Following that I connected my Laravel app going through the docs. Initially I thought it perhaps a memory issue so I upped the memory to 2GB but the issue still persists.

Here is my MySQL app config:

And here is my Laravel app config:

You can also take a quick look at my website to observe the behaviour. You may need to refresh a few times.

Hi!

I can see that error happening, yep!

I would SSH into each instance and run a “mysql -h -u -p” to see if any specific application instances get a connection refused error.

I think I see most connection refused errors coming from Laravel app instances in LHR (where the database also is). Perhaps try hostname cujaneway-mysql.internal instead of lhr.cujaneyway-mysql.internal.

1 Like

Those changes to config look to have fixed it, I’m unable to replicate the issue now. Though I’m curious as to why they were happening at all. Thanks for your help!

Hi!

That might actually be a coincidence, there may have been something funky going on with the server those apps were hosted on. We got that cleared up, which may be more the reason why that is working for you now (I’d be curious if you changed that back to the lhr. hostname if it continues to work!)

2 Likes

Redeployed with region.appname.internal and it looks to be working as intended with the region; even fixed some issue I was experiencing with Vite that I had assumed was my own, no idea how that impacted it! Appreciate the help :slight_smile:.

1 Like