Connect Google Sheets To A Database

Skip to first unread message

Anthony Apollis

Feb 26, 2021, 4:58:14 AM2/26/21
to Google Apps Script Community

I would like to connect to a mysql database that is a localhost connection and not on a internet service provider.
How do i connect? Do you use "localhost or your ip"?

I tried it and it does not work. Also, how do i open a port for access? Is the port connections blocking me from succeeding regarding this?

Feb 26, 2021, 7:09:41 AM2/26/21
to Google Apps Script Community
Apps Script's JCBC library can only connect to database servers that are accessible from the web. So it cannot connect directly to your local database unless you host it online. 
But there are services that allow you to do that. ngrok is one such service. 

Anthony Apollis

Feb 26, 2021, 7:25:36 AM2/26/21
Thank you for your response. I didnt know that. If im connecting to database, remotely e.g via vpn. Will that work?


You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Clark Lind

Feb 27, 2021, 9:27:41 AM2/27/21
to Google Apps Script Community
No, not likely. Because Apps script is running on Google servers (not on your machine), the Google servers have to reach out to make a connection to the database wherever it happens to be. If you are using a router and have control over it, most routers these days have port forwarding capabilities. But that is beyond the scope of this group. 
Reply all
Reply to author
0 new messages