MYSQL deployment
frost-jm
TRIALOP

2 years ago

I'm just new to render. I wanted to host my database which is MySQL.
but on deployment logs I see an error. I'm using the mysql docker image provided in the default config.

[Server] /usr/sbin/mysqld: ready for connections. Version: '8.3.0' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.

May I know the reason or how to fix this?

Solved

10 Replies

brody
EMPLOYEE

2 years ago

Render? this is the Railway help station.


frost-jm
TRIALOP

2 years ago

Sorry. I mean railway.


brody
EMPLOYEE

2 years ago

That would have been funny if you did mean Render.

But you haven't provided any errors yet. What issues are you facing?


frost-jm
TRIALOP

2 years ago

This is what im getting in the logs

Attachments


brody
EMPLOYEE

2 years ago

Red doesn't always mean error, in this case, they are red because MySQL sent the logs to stderr.

Looking at the contents of the logs and not the color, I'm not seeing any errors, so please tell me what issues you are running into.


frost-jm
TRIALOP

2 years ago

So yeah, I have created another service which has a node + express + graphql. Then i'm trying to connect to the MySQL service.

but then i'm getting this from deployment log. I already filled up the env variables for the database.

Error: Error: connect ETIMEDOUT

at PoolConnection._handleTimeoutError (/app/node_modules/mysql2/lib/connection.js:205:17)

at listOnTimeout (node:internal/timers:569:17)

at process.processTimers (node:internal/timers:512:7) {

errorno: 'ETIMEDOUT',

code: 'ETIMEDOUT',

syscall: 'connect',

fatal: true

}

brody
EMPLOYEE

2 years ago

Can you show me your mysql client code, please?


frost-jm
TRIALOP

2 years ago

Here.

const mysql = require('mysql2');

const pool = mysql.createPool({
    host: process.env.DB_HOST,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD || '',
    database: process.env.DB_NAME,
    connectionLimit: 10,
});

const keepConnectionAlive = async () => {
    try {
        const connection = await pool.promise().getConnection();
        console.log('Connected to the database');

        await connection.query('SELECT 1');
        console.log('Connection live');

        connection.release();
    } catch (err) {
        console.error('Error:', err);
    }
};

const interval = 50000;
setInterval(keepConnectionAlive, interval);

module.exports = { pool };

frost-jm
TRIALOP

2 years ago

Thanks for the help. Already solved it!


brody
EMPLOYEE

2 years ago

Happy you solved it, and for anyone else, they were missing the port field in their pool object.


Status changed to Solved Railway over 1 year ago


Loading...