简体   繁体   English

错误:连接 ECONNREFUSED 185.176.43.99:3306

[英]Error: connect ECONNREFUSED 185.176.43.99:3306

I'm trying to use my biz.nf database in node.js programme but I'm getting a connection refused error.我正在尝试在 node.js 程序中使用我的 biz.nf 数据库,但出现连接被拒绝错误。 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) })

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?您确定您的托管服务提供商允许这样做并且已启用从 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.要像您在这里所做的那样从外部应用程序连接,您可能需要通过一些中间服务(例如 SSH 或 VPN 隧道)或通过从服务器实现自定义 API 来中继连接。 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.另一种解决方案可能是直接在主机的服务器上运行应用程序,因为它已经在主机的网络上,因此可以直接连接到数据库服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM