Trouble connecting to mysql

I created a new vapor project with Fluent and I'm having trouble connecting to my mysql instance on my Synology server. I tried a different db management app with the same credentials and connection settings and it works fine. This use to work on my MacBook Pro M1 before that died. Now I'm on a 2018 MBP with i9. Here's the error:

[ ERROR ] Opening new connection for pool failed: connect(descriptor:addr:size:): No route to host (errno: 65) [database-id: mysql, request-id: 88507221-099C-4786-85D9-5BF6207652EC]

[ WARNING ] connect(descriptor:addr:size:): No route to host (errno: 65) [request-id: 88507221-099C-4786-85D9-5BF6207652EC]

Thanks for any help.

1 Like

No route to host is a fun error! What host are you connecting to?

Just to confirm - you're running the Vapor app on macOS (not in Docker or a virtualised system) and you can connect via a DB management app on the same system?

I’m running from xcode on 2018 MacBook Pro with i9. The db is served from synology connected to the same local network. The db management software hat works is also on the same MBP. For some reason fluent can’t connect. Vapor/Fluent worked before when I was using an M1 MBP.

Can you connect via the command line using mysql? What version of Swift are you using?

i'm using swift 6. Having an issue with command line mysql so i'm debugging that. I use TablePlus and that connects fine.

I did another test with a cloud db and it's working. I now suspect that it didn't respect my port configuration as i'm not using the standard 3306 on my synology. Any idea what I can do to fix? Like I mentioned, this was working on my previous MBP.

I have this line in my config

port: Environment.get("DATABASE_PORT").flatMap(Int.init(_:)) ?? MySQLConfiguration.ianaPortNumber,

and DATABASE_PORT is set

No route to host would imply that it's nothing to do with the port, that would result in a connection refused error normally

I tested making different parts wrong with the cloud db connection to see what errors i get.

bad port

{"reason":"connection reset (error set): Connection refused (errno: 61)","error":true}

bad host

{"reason":"unknown(host: \"[hostname hidden]\", port: 3306)","error":true}

bad database name

{"reason":"MySQL error: Server error: Access denied for user '[user hidden]'@'%' to database '[database name hidden]'","error":true}

What's the actual error you're getting when trying to connect to your Synology? Because "connection refused" is very different to "no route to host"

And second, what's the hostname you're using? Is it synology.local or similar? It might be because the hostname can't be discovered if it's only available via Bonjour for instance

[ ERROR ] Opening new connection for pool failed: connect(descriptor:addr:size:): No route to host (errno: 65) [database-id: mysql, request-id: 93C4FF7D-1183-43F8-B78B-9BE1FFE6BD93]
[ WARNING ] connect(descriptor:addr:size:): No route to host (errno: 65) [request-id: 93C4FF7D-1183-43F8-B78B-9BE1FFE6BD93]

I am using a hostname like synology.local. however i tried with ip and same result.

If you can connect on the same machine via IP with a different client there's no reason why that shouldn't work with Vapor. Do you get the exact same error message when using an IP address

I agree it should work with Vapor as well, but for some reason it doesn't. For sanity check, I tried connecting via TablePlus again a few times and it all connected just fine.

Yes. same message whether ip or hostname.