Argon
Argon
RRailway
Created by Argon on 5/18/2023 in #✋|help
App's DB connection timing out when trying to connect to Railway MySQL database
Thanks for the help! @ImLunaHey @ThallesComH
18 replies
RRailway
Created by Argon on 5/18/2023 in #✋|help
App's DB connection timing out when trying to connect to Railway MySQL database
Edited it and now it works
18 replies
RRailway
Created by Argon on 5/18/2023 in #✋|help
App's DB connection timing out when trying to connect to Railway MySQL database
Anyways turns out it was the port, when I forked it and worked on it I never notice it used the default port
18 replies
RRailway
Created by Argon on 5/18/2023 in #✋|help
App's DB connection timing out when trying to connect to Railway MySQL database
Project requirements 🥲
18 replies
RRailway
Created by Argon on 5/18/2023 in #✋|help
App's DB connection timing out when trying to connect to Railway MySQL database
I swear if it's because I forgot about that variable
18 replies
RRailway
Created by Argon on 5/18/2023 in #✋|help
App's DB connection timing out when trying to connect to Railway MySQL database
Oh god
18 replies
RRailway
Created by Argon on 5/18/2023 in #✋|help
App's DB connection timing out when trying to connect to Railway MySQL database
database.js
const mysql2 = require('mysql2/promise');

console.log(`Creating a MySQL pool with the following information:\nuser: ${process.env.DB_USER}\nhost: ${process.env.DB_HOST}\ndatabase: ${process.env.DB_DATABASE}`)
const pool = mysql2.createPool({
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
host: process.env.DB_HOST,
database: process.env.DB_DATABASE,
connectionLimit: process.env.DB_CONNECTION_LIMIT,
ssl: {
rejectUnauthorized: false,
},
});

// Monkey patch .query(...) method to console log all queries before executing it
// For debugging purpose
const oldQuery = pool.query;
pool.query = function (...args) {
const [sql, params] = args;
console.log(`EXECUTING QUERY`, sql, params)
return oldQuery.apply(pool, args);
};

module.exports = pool;
const mysql2 = require('mysql2/promise');

console.log(`Creating a MySQL pool with the following information:\nuser: ${process.env.DB_USER}\nhost: ${process.env.DB_HOST}\ndatabase: ${process.env.DB_DATABASE}`)
const pool = mysql2.createPool({
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
host: process.env.DB_HOST,
database: process.env.DB_DATABASE,
connectionLimit: process.env.DB_CONNECTION_LIMIT,
ssl: {
rejectUnauthorized: false,
},
});

// Monkey patch .query(...) method to console log all queries before executing it
// For debugging purpose
const oldQuery = pool.query;
pool.query = function (...args) {
const [sql, params] = args;
console.log(`EXECUTING QUERY`, sql, params)
return oldQuery.apply(pool, args);
};

module.exports = pool;
This is where I run the query
const {query} = require('./database');

module.exports = {
create_user: (customer) => {
const { first_name, last_name, email, password } = customer;
const sql = `INSERT INTO users(first_name, last_name, email, password) VALUES(?, ?, ?, ?)`
return query(sql, [first_name, last_name, email, password])
}
}
const {query} = require('./database');

module.exports = {
create_user: (customer) => {
const { first_name, last_name, email, password } = customer;
const sql = `INSERT INTO users(first_name, last_name, email, password) VALUES(?, ?, ?, ?)`
return query(sql, [first_name, last_name, email, password])
}
}
This is the stdout in my Deploy Logs:
EXECUTING QUERY INSERT INTO users(first_name, last_name, email, password) VALUES(?, ?, ?, ?) [ redacted ]
Error: connect ETIMEDOUT
at PromisePool.query (/app/node_modules/mysql2/promise.js:341:22)
at pool.query (/app/model/database.js:21:21)
at Object.create_user (/app/model/user.js:8:16)
at /app/router/user.js:13:10
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:144:13)
at Route.dispatch (/app/node_modules/express/lib/router/route.js:114:3)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at /app/node_modules/express/lib/router/index.js:284:15
at Function.process_params (/app/node_modules/express/lib/router/index.js:346:12) {
code: 'ETIMEDOUT',
errno: undefined,
sql: undefined,
sqlState: undefined,
sqlMessage: undefined
}
EXECUTING QUERY INSERT INTO users(first_name, last_name, email, password) VALUES(?, ?, ?, ?) [ redacted ]
Error: connect ETIMEDOUT
at PromisePool.query (/app/node_modules/mysql2/promise.js:341:22)
at pool.query (/app/model/database.js:21:21)
at Object.create_user (/app/model/user.js:8:16)
at /app/router/user.js:13:10
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:144:13)
at Route.dispatch (/app/node_modules/express/lib/router/route.js:114:3)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at /app/node_modules/express/lib/router/index.js:284:15
at Function.process_params (/app/node_modules/express/lib/router/index.js:346:12) {
code: 'ETIMEDOUT',
errno: undefined,
sql: undefined,
sqlState: undefined,
sqlMessage: undefined
}
18 replies
RRailway
Created by Argon on 5/18/2023 in #✋|help
App's DB connection timing out when trying to connect to Railway MySQL database
Yep, it works locally
18 replies
RRailway
Created by Argon on 5/18/2023 in #✋|help
App's DB connection timing out when trying to connect to Railway MySQL database
95a2bc67-6c87-48fb-8d39-5d7dca258f75
18 replies
RRailway
Created by Argon on 4/22/2023 in #✋|help
Installing ImageMagick for a Python project
Ah I don't really get what you mean
8 replies
RRailway
Created by Argon on 4/22/2023 in #✋|help
Installing ImageMagick for a Python project
8 replies
RRailway
Created by Argon on 4/22/2023 in #✋|help
Installing ImageMagick for a Python project
Like during the free tier period
8 replies
RRailway
Created by Argon on 4/22/2023 in #✋|help
Installing ImageMagick for a Python project
Before adding the Nixpacks.toml file, I had this project deployed on Heroku with no issues
8 replies
RRailway
Created by Argon on 4/22/2023 in #✋|help
Installing ImageMagick for a Python project
755b9377-178d-4b4d-9cc2-1357a4459901
8 replies
RRailway
Created by Argon on 3/23/2023 in #✋|help
Changed Procfile command but command hasn't changed in Railway
It's removed
9 replies
RRailway
Created by Argon on 3/23/2023 in #✋|help
Changed Procfile command but command hasn't changed in Railway
Oh okay sorry CatThumbsUp
9 replies
RRailway
Created by Argon on 3/23/2023 in #✋|help
Changed Procfile command but command hasn't changed in Railway
Not sure how to close this but I'm all good now, thanks
9 replies
RRailway
Created by Argon on 3/23/2023 in #✋|help
Changed Procfile command but command hasn't changed in Railway
Never mind, when I was finding my project ID i found the setting to change the command. Silly me 😅
9 replies