共计 568 个字符,预计需要花费 2 分钟才能阅读完成。
{Error: getaddrinfo ENOTFOUND localhost localhost:27017
at errnoException (dns.js:50:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
code: ‘ENOTFOUND’,
errno: ‘ENOTFOUND’,
syscall: ‘getaddrinfo’,
hostname: ‘localhost’,
host: ‘localhost’,
port: 27017 }
mongoose.connect(‘mongodb://localhost:27017/db1’,{
poolSize:5,
useNewUrlParser: true
},err=>{
if(err){
console.error(err)
}else {
console.log(‘mongodb 连接成功 ’)
}
})
将 localhost 修改为 127.0.0.1 试试
mongoose.connect(‘mongodb://127.0.0.1:27017/db1’,{
poolSize:5,
useNewUrlParser: true
},err=>{
if(err){
console.error(err)
}else {
console.log(‘mongodb 连接成功 ’)
}
})
正文完