Failing to connect to Google Cloud MySQL Database from Glitch

I’ve built a mySQL database on Google Cloud using my locally installed WorkBench. ( no problem connecting to the database from my PC)

However I now want my app on Glitch to connect to it. I’m using this JS code to connect to my database hosted on Google cloud
const mysql = require(‘mysql’);

    var con = mysql.createConnection({
      host: process.env.SERVER,
      database: process.env.DATABASE_NAME,
      user: process.env.USER_NAME,
      password: process.env.PASSWORD

    con.connect(function(err) {
      if (err) throw err;

I’ve double checked that my env file holds all the correct values
In order for Google to allow a connection I have to specify the public IP that will be attempting the connection.
What Glitch ip address should I use for me to add Glitch to Google’s whitelist?

Open up the glitch console and run this curl, that should give you Glitch’s ip address :slight_smile:

The issue with that is that Glitch container IPs change from time to time. If you plan on using Glitch for the long run, you should be prepared to whitelist a new IP from time to time.

1 Like

Nice one - That worked a treat

I was using the iP address derived from my shared Glitch URL - https://necessary-stump-****
I completely different IP address which would explain why it wasn’t working for me.

And I accept this solution isn’t cast in stone and That I will need to periodically update the IP address as and when the issue returns.

I hope this helps others who are travelling a similar path . . .

1 Like

you could use , but that whitelists every address is an internal address, no?

1 Like

In the Internet Protocol Version 4, the address 0.0. 0.0 is a non-routable meta- address used to designate an invalid, unknown or non-applicable target. This address is assigned specific meanings in a number of contexts, such as on clients or on servers.

In MongoDB you can do or something to whitlelist all ips


I mean you could as Glitch for every IP they are using.

This :point_up: would be the ideal solution and the IP to whitelist.



Works a treat but comes with a warning as already discussed


If you are going to whitelist all ips, you should be sure to make a strong password.


Unless you are constantly logging into it. I would recommend to make the pssword a sha526 has.

You mean a sha512 or a sha256 hash?

  1. I am on iPad.