Error: Error: getaddrinfo ENOTFOUND "sql12.freemysqlhosting.net"

For my react-Node app, I have hosted the frontend and backend code on render and I am using a third-party website (freemysqlhosting.net) for hosting my database. I have successfully deployed both my front and backend on render.com, but once the site goes live, i get this error from the backend code.

Error: Error: getaddrinfo ENOTFOUND "sql12.freemysqlhosting.net"
Sep 23 04:01:45 PM      at PromisePool.query (/opt/render/project/src/Server/node_modules/mysql2/promise.js:356:22)
Sep 23 04:01:45 PM      at getNotes (file:///opt/render/project/src/Server/database.js:17:31)
Sep 23 04:01:45 PM      at Server.<anonymous> (file:///opt/render/project/src/Server/server.js:31:34)
Sep 23 04:01:45 PM      at Server.emit (events.js:376:20)
Sep 23 04:01:45 PM      at parserOnIncoming (_http_server.js:896:12)
Sep 23 04:01:45 PM      at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17) {
Sep 23 04:01:45 PM    code: 'ENOTFOUND',
Sep 23 04:01:45 PM    errno: -3008,
Sep 23 04:01:45 PM    sql: undefined,
Sep 23 04:01:45 PM    sqlState: undefined,
Sep 23 04:01:45 PM    sqlMessage: undefined
Sep 23 04:01:45 PM  }

Upon some research, i found that this could be an issue related to not correctly setting up a database connection, so Itried doing, it, checked my db credentials but the error’s still there.

This is how I am setting up my database:

const pool = createPool(
    {
        host: process.env.MYSQL_HOST,
        user: process.env.MYSQL_USER,
        password: process.env.MYSQL_PASSWORD,
        database: process.env.MYSQL_DATABASE
    }
).promise();

and this is the .env file for the ENV variables:

MYSQL_HOST='sql12.freemysqlhosting.net'
MYSQL_USER='sql12648461'
MYSQL_PASSWORD='*********'
MYSQL_DATABASE='sql12648461'

Any help would be great,
Thanks

Hi there,

Did you get this resolved, As this is service related it might be better to contact us directly so we can link the ticket up with the service in question,

Regards

John B
Render Support, UTC+1 :uk:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.