Just installed MySQL locally, and created a db and one simple table. I'm now trying to connect to it from Google Sheets, but it fails with err:

`{ [Exception: Invalid argument: url] name: 'Exception' } undefined`

Much googling later, it seems that because Sheets runs on google servers, it can't resolve `localhost` as a Host.

Is there a way around this?

```
var HOST      = 'localhost';
var PORT      = '3306';
var USERNAME  = 'xxxx';
var PASSWORD  = 'xxxx';
var DATABASE  = 'investment';
var DB_TYPE   = 'mysql';
var MAXROWS   = 1000;

function testConnection(){
    var sql = doc.getRange('query!a2').getDisplayValue();
    var options = {};
}
function runSql(query, options) {
    try {
        var fullConnectionString = 'jdbc:' + DB_TYPE + '://' + HOST + ':' + PORT;
        var conn = Jdbc.getConnection(fullConnectionString, USERNAME, PASSWORD);
        Logger.log('conn :', conn);
        Logger.log('query :', query);
        var stmt = conn.createStatement();
        stmt.execute('USE ' + DATABASE);
        var start = new Date();
        var stmt = conn.createStatement();
        stmt.setMaxRows(MAXROWS);
        var rs = stmt.executeQuery(query);
    } catch (e) {
        console.log(e, e.lineNumber);
        Browser.msgBox(e);
        return false;
    }
}

```

Just wondering, if I could find a way of getting my IPv4 address online (since it would be DHCP I think, so changing periodically), could I use Host such as `101.146.72.23/localhost`? (*not my real IP*)

**[Edit]** I tried adding my IPv4 address as above, and maybe that took me a step closer, as now I get a different error:

`{ [Exception: Failed to establish a database connection. Check connection string, username and password.] name: 'Exception' } undefined`

While reading up on [Google: JDBC](https://developers.google.com/apps-script/guides/jdbc), it states "*In order to create a database connection using the JDBC service you must allow-list certain IP ranges in your database settings to allow Apps Script to access it. These are the address ranges you'll need to allow-list.*"

Now searching on how to do this in Windows 10.

**[Edit 2]** Reporting progress for anyone else who needs to do this. Following @Julian Benavides suggestions, I found a link on how to [Add Port Forwarding on Telstra Smart Modem](https://portforward.com/telstra/smart-modem-gen-2/) . This post pointed out that my pc would need a Static IP address (on the local network), at [How to Setup a Static IP Address on a Computer](https://portforward.com/networking/staticip.htm).

I *think* I have made a successful connection, although now I have to figure out why I have error:

`Exception: Table 'investment.investment_type' doesn't exist`

Getting closer, but no cigar yet.

**[Edit 3 - Success!]** I had the wrong table name, now works!