Previously working Google Sheets App Script is now throwing the "Failed to establish a database connection" error for MySQL DB

Viewed 456

I've been using Google Sheets App Script successfully the past 4 months that is connected to a MySQL 5.7 DB hosted remotely on a VPS (this script connected to my DB successfully earlier today as well). All of a sudden this afternoon my requests are returning "Failed to establish a database connection. Check connection string, username and password." The database connection still works just fine remotely on my computer using MySQL Workbench.

Additional details:

  • The credentials didn't change (I confirmed with a new connection test)
  • I have Chrome V8 Runtime disabled since that does not work well at all
  • I double checked the Google Server IPs to whitelist and noticed 1 server that's either new or I missed the first time, either way all provided IPs are currently whitelisted
  • I'm connecting using this syntax: var conn = Jdbc.getConnection(url, user, pwd);

I saw some previous comments from a month ago that some people were able to add these parameters successfully: var conn = Jdbc.getConnection(url+'?verifyServerCertificate=false&useSSL=true&requireSSL=true', user, pwd); However I just get this: Error Invalid argument: _serverSslCertificate

Any further steps or tips to get this connected successfully again is appreciated, thanks!

3 Answers

Austin, you just made my day... Same thing, my MySQL connections stopped working all of a sudden yesterday. Spent hours trying to fix it. The '?useSSL=false' worked like charm.

Thank you, thank you, thank you

I found a solution.

Seems a change on Google now requires you to explicitly set SSL to false. (previously if you let it omitted it would default to off)

?useSSL=false

So you need to update your connection string to something like this simple example.

function myFunction() {

var conn = Jdbc.getConnection("jdbc:mysql://35.214.129.151:3306/dbiyrogncria1r?useSSL=false", "uyxfedtljijfy8", "rnqgnyrs2dthb");

Logger.log(conn);
conn.close();
}

Apparently it's just working again.... must have been a service blip. What's strange is it started working again after I decided to just try var conn = Jdbc.getConnection(url+'?useSSL=false', user, pwd); since I saw some other comments mention that. Seems like an awful solution, but it started working again after I did that, but has continued to work even after I reverted back to just var conn = Jdbc.getConnection(url, user, pwd);

Follow-up questions, are there any good alternatives to Google Sheets with App Script like usage? I'm getting really tired of Google's awful support - would rather pay for a product than to hear "you get what you pay for" with awful support.

EDIT: After this started working again yesterday by itself, the issue came back. I have now confirmed today that switching to var conn = Jdbc.getConnection(url+'?useSSL=false', user, pwd); has solved my connection issue, but that is not an ideal fix by any means at all. Google must be messing with some network settings on the Apps Script side and it's causing issues.

Related