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;
console.log("Connected!");
});
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?
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.
I was using the iP address derived from my shared Glitch URL - https://necessary-stump-****.glitch.me
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 . . .
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.