By zhangboyu
const MYSQL_CONF = {
host: 'db-mysql-v1-29254-do-user-7904424-0.a.db.ondigitalocean.com',
username: 'doadmin',
password: 'xxxxxxxx',
database: 'defaultdb',
// port: 25060,
dialect: 'mysql',
dialectOptions: {
ssl: {
ssl: true,
cert: fs.readFileSync(path.resolve(__dirname, 'ca-certificate.crt')).toString('utf8')
}
}
}
const con = mysql.createConnection(MYSQL_CONF)
con.connect((err, result) => {
if (err) {
throw new Error(err)
return
}
});
The configuration is coded above, and i am not sure if this is the correct one…The error always states the Error: connect ETIMEDOUT…
the funny thing is that i can connect the cluster with mysql client terminal and workbench on my local machine, but it doesn’t work with node.js…
Could someone help me out, many thanks?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @zhangboyu, I have the same issue, During my development stage I established many connection pools to the database, after some time database firewall blocks my request, so set up a VPN and tried again and it will work. Solution: Try some VPN
Hi there @zhangboyu,
I can see that the custom port is commented out, you need to have that port specifically defined in your connection string.
Another thing that I would recommend trying to create a new user with MySQL native password and try using it instead of the default user. You can do that via your DigitalOcean control panel.
Also if your Node.js app is running on a Droplet, I would recommend checking if port 25060 is open for outgoing TCP connections, to test that you can use the following telnet command:
- telnet your_db_host.db.ondigitalocean.com 25060
Let me know how it goes! Regards, Bobby
@zhangboyu did you ever figure this out? I’m having the same exact issue I can connect with workbench but not with node mysql
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.