在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") })
错误日志截图:


内容的提问来源于stack exchange,提问作者Shriyash
相关产品推荐
相关产品推荐

