Connecting to MySQL database from a glitch app, throws "ETIMEDOUT" error?

I’m creating a web app which stores data from client-side. The following is an example of what the app does before storing data:!/mcve

In logs, I’m getting “…error ETIMEDOUT…”. However, my credentials are correct (as it doesn’t throws error: ECONNREFUSED, which it’d thrown earlier). But, I can’t connect to mysql. Is this bcoz of nodejs code OR am I taking glitch too lightly?

The server-side code is:

let mysql = require('mysql');
let conn = mysql.createConnection({
  user: 'root',
  host: process.env.MYIP,
  database: process.env.MYDB,
  password: process.env.PASS
conn.connect(err => {

I’ve tried:

  • setting connectTimeout
  • setting createPool
  • command mysql> GRANT ALL ON fooDatabase.* TO fooUser@'' IDENTIFIED BY 'my_password';

The whole error log:

Error: connect ETIMEDOUT

    at Connection._handleConnectTimeout (/***/pnpm-volume/******/node_modules/

    at Object.onceWrapper (events.js:284:20)

    at Socket.emit (events.js:196:13)

    at Socket._onTimeout (net.js:432:8)

    at listOnTimeout (internal/timers.js:531:17)

    at processTimers (internal/timers.js:475:7)


    at Protocol._enqueue (/***/pnpm-volume/*******/node_modules/

    at Protocol.handshake (/***/pnpm-volume/*******/node_modules/

    at Connection.connect (/***/pnpm-volume/*******/node_modules/

at Object.<anonymous> (


    at Module._compile (internal/modules/***/loader.js:759:30)

    at Object.Module._extensions..js (internal/modules/***/loader.js:770:10)

    at Module.load (internal/modules/***/loader.js:628:32)

    at Function.Module._load (internal/modules/***/loader.js:555:12)

    at Function.Module.runMain (internal/modules/***/loader.js:826:10)

    at internal/main/run_main_module.js:17:11 {

  errorno: 'ETIMEDOUT',

  code: 'ETIMEDOUT',

  syscall: 'connect',

  fatal: true


Also, are there any better and efficient, free-of-cost alternatives to mysql, which web dev use these days to store their sites data?


Can you check these two conditions in your mysql server:

  1. remote connection to mysql server is enabled (no firewall rule to drop the request) - (I think this is not the problem)
  2. remote connection is enabled for this mysql user (

As you said that the first one isn’t required, so I didn’t checked it (as I don’t know how to do so).

I checked out the second one, using the “grant all…” command, but it said “Query OK, 0 rows affected”. Does this means that remote connection was already enabled?

Also, as mentioned in the post, I did a test on remote connection by running

mysql -u fooUser -p -h

command, but it said “Can’t connect to MySQL server on ‘’ (10060)”

The link I sent you is an example how to enable access to a remote user, the IP addresses are example addresses, you need to adapt them to your case. The “Query OK…” means that the sql command was successfully executed, but if you used the fooUser in your command, then 0 rows were affected because I think you do not have a user named fooUser.

Based on what you wrote, I am not sure that your mysql server is available in an external IP. Here is another post about how to enable remote access to the entire mysql server:

Please make sure that you use the correct IP address in the configuration file (the IP address of your virtual machine or physical host your mysql server is running on.

I will try to help you more if you describe where is you mysql server running.

  • Is it on a virtual machine?
  • If so, where is the VM hosted? AWS, Azure, or is the mysql server running on your local machine?
  • What is the OS of the machine the server is running on?

I had used root in place of fooUser and myPassword in place of fooPassword so my first cmd was acc. to my account.

Actually, I’ve learnt MySQL cmds, but I’m a real noob in setting up MySQL server and networking.

I’ve installed MySQL command line client to run MySQL on my Windows 10 laptop. I’ve read that XAMPP turns on Apache and MySQL server, so I have installed XAMPP and did that.

XAMPP turns on Apache, but says that MySQL is already running on port 3306. Also, I’ve worked with MySQL on localhost, which was fine without any problems.

As per your reply, it seems that host in config object is the IP of my laptop, which I’ve got by running ipconfig cmd in Windows shell. Also, I’d not configured .cnf file as I don’t know the name of that file.

You can go into the XAMPP configuration and change what ports things run on (Config -> Service and Port Settings -> MySQL Tab -> Edit Main Port -> Save)
To use your own MySQL on Glitch you’ll need to port forward the port you choose via your router’s settings and then connect to your external IP Address (not the same as the one shown in ipconfig - to find this one you can search on google what is my IP address) Correct me if any of this is wrong - never tried it myself but I have port forwarded a XAMPP Apache server

Update: I’ve used Mongodb after suggestion by many members and their projects. And, now I’m working with it smoothly, it is fast and secure.
BUT, still MySQL is my favorite free-db, and I would like to use it. :star_struck:

As per your reply, I did checked my ext. ip which was not same as my prev. ip. I guess it is due to the fact that I’m connected to a hotspot. I got the same ip by a req.ip line in express!
Now, I’ve edited that in .env file. But, I’m getting the same error.

For the XAMPP part, it is already listening to port 3306, which is my MySQL’s port. I think my XAMPP isn’t working properly, as shown


I didn’t understood what you meant by “port forward the port”… :thinking:

Port forwarding is allowing the port to be accessed from another computer that isn’t on your broadband or network and your router usually has simple settings to allow you to do this. You will probably also need to set up a static IP address if you want to use your own SQL database on Glitch

1 Like

And, that means I’ve to go with NoSQL’s like MongoDB, until I could own something which could help me to “port forward”.
Many thanks for this useful info.

Most consumer routers will have that option though (May be in advanced section). For example, I use my ISP’s (Virgin Media here in the UK) provided router and it has these options