Error: connect ECONNREFUSED 185.176.43.99:3306

Viewed 28

I'm trying to use my biz.nf database in node.js programme but I'm getting a connection refused error. Error: Code error

Code:

const {createPool} = require("mysql")

const pool = createPool({
  host: "fdb27.biz.nf",
  port: 3306,
  user: "3723359_coolbot",
  password: process.env.pass,
  database: "3723359_coolbot"
})

pool.query('SELECT * FROM FirstTable', function (err, result, fields) {
 if(err) return console.log(err)
 console.log(result) })
1 Answers

Most hosts disallow connecting directly to a database from a remote system. Are you certain your hosting provider allows this and has enabled access from all points on the internet? This is generally considered a security concern so it's unlikely they allow this by default.

To connect from an external application as you seem to be doing here, you'll probably need to relay your connection through some intermediary service such as an SSH or VPN tunnel or by implementing a custom API from the server. Another solution could be to run the application directly on your host's servers which would be able to connect directly to the database server since it's already on your host's network.

Related