How to connect to MySQL DB in Aiven

https://paragonsmp.rf.gd/

Error Message

SQLSTATE[HY000] [2002] Connection refused

Other Information

Hello, I’m trying to connect my website hosted on Infinity Free to an external MySQL database (Aiven). The connection works perfectly locally, but when I try to connect in the production environment (Infinity Free), I get the error above.

It’s possible that the external site is blocking access from InfinityFree servers, you’ll have to contact them about this.

7 Likes

Have you configured your Aiven VPC (I assume your using their VPC service for your database?) to accept public connections?

This might help

4 Likes

I don’t think so because my Minecraft (Java) server is able to connect to it, there must be a issue/blocking in Infinity Free

That’s not necessarily the case. Even a database server that is accessible from other networks can (and often should) have rules that restrict from which IP addresses the database server is accessible. If your database server allows connection from your Minecraft server, but not from your hosting server, you still wouldn’t be able to access it.

I’ve asked our supplier about this and they say that access to remote database servers should be possible, although I didn’t actually verify yet whether it actually works.

4 Likes

I just signed up with Aiven myself to test it for myself, and I already see the problem.

Our servers allows outbound MySQL database connections on the normal MySQL port. Access to custom ports is blocked on our hosting.

But Aiven appears to host their MySQL databases on a randomized port number. And you’re basically guaranteed that this random port is blocked.

So yes, you should be able to connect to external databases, just not in the way that Aiven has setup their databases.

7 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.