You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在cPanel部署NodeJS项目时无法通过mongoose.connect连接MongoDB Atlas

部署cPanel后NodeJS无法连接MongoDB Atlas排查求助

我正在为学校搭建网站,采用NodeJS搭配MongoDB作为数据库。项目在本地机器和Heroku上运行正常,但部署到cPanel后出现连接问题——无法连接MongoDB Atlas,导致无法获取数据。从错误日志推测问题可能出在mongoose.connect()方法,但不确定是否存在其他诱因。

附上mongoose连接代码:

mongoose.connect("mongodb+srv://usernmae:password@cluster0.1laezrl.mongodb.net/Yearbook10",
    {
      useNewUrlParser: true,
      useUnifiedTopology:true
    }
    ).then(()=>{
      console.log("Connected with the db")
    })

错误日志截图:

cPanel中NodeJS错误日志1
cPanel中NodeJS错误日志2

内容的提问来源于stack exchange,提问作者Shriyash

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 23:12:21