[英]ConnectionError: Failed to connect to {database server} - Could not connect (sequence)
I'm running this node.js application on a shared hosting site (cPanel) and run into this connection problem to the RDS SQL Server and I'm not sure what I can do to get more information on the problem so I can fix it or how to fix it. 我在共享托管站点(cPanel)上运行此node.js应用程序,并遇到了与RDS SQL Server的连接问题,我不确定该怎么做以获取有关此问题的更多信息,以便对其进行修复。或如何解决。
I can successfully connect to the SQL Server using SMSS, furthermore, using the SAME node.js code I can connect to the SQL Server on my main desktop. 我可以使用SMSS成功连接到SQL Server,此外,可以使用SAME node.js代码连接到主桌面上的SQL Server。 This connection problem only occurs when running the same code on cPanel. 仅当在cPanel上运行相同的代码时,才会出现此连接问题。
I have allowed all IP address access (All traffic inc TCP/UDP)through the RDS VPC security group: 0.0.0.0/0 我已允许通过RDS VPC安全组的所有IP地址访问(所有流量,包括TCP / UDP):0.0.0.0/0
I'm just confused as it works on my desktop but does not work on the hosting site, as the security group allows all access from all IP's. 我只是感到困惑,因为它可以在我的桌面上工作,但不能在托管站点上工作,因为安全组允许所有IP的所有访问。 Is possible for the hosting site to prevent connections to databases and is something I should look into? 托管站点是否可以阻止与数据库的连接,我应该研究一下吗?
ERROR: 错误:
ConnectionError: Failed to connect to - Could not connect (sequence) ConnectionError:无法连接-无法连接(顺序)
Failed to connect to - Could not connect (sequence) 连接失败-无法连接(顺序)
code: 'ESOCKET' 代码:“ ESOCKET”
name: 'ConnectionError' 名称:“ ConnectionError”
Code used to connect to the database: 用于连接数据库的代码:
// config for your database
var config = {
user: ...,
password: ...,
server: ...,
database: ...,
port: 1521,
dialect: "mssql",
dialectOptions: {
instanceName: "SQLEXPRESS"
}
};
// connect to your database
sql.connect(config, function (err) {
if (err) console.log(err);
});`
Found the answer. 找到了答案。 Brad was right, this is a cPanel specific problem. 布拉德说得对,这是cPanel的特定问题。
As I'm using shared hosting on cPanel (through namecheap), connecting to a SQL SERVER or any remote database instance is not permitted for security reasons. 由于我在cPanel上使用共享主机(通过namecheap),出于安全原因,不允许连接到SQL SERVER或任何远程数据库实例。
If anyone wishes to connect to a remote database using the same methods, ensure you do not have shared hosting. 如果有人希望使用相同的方法连接到远程数据库,请确保您没有共享主机。 :( :(
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.