MongoError:getaddrinfo ENOTFOUND undefined undefined:27017 [英] MongoError: getaddrinfo ENOTFOUND undefined undefined:27017

查看:1105
本文介绍了MongoError:getaddrinfo ENOTFOUND undefined undefined:27017的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我按照Manning的Getting Mean书和第5章中的步骤努力工作。我尝试在Mongolab上使用db作为Heroku的附加组件。当我运行这个代码(本地和Heroku)时,它会返回这个错误:

So I'm working my way though the Getting Mean book from Manning and following the steps in Chapter 5 I'm trying to use a db on Mongolab as an add-on to Heroku. When I run this code (both locally and on Heroku) it returns this error:


MongoError:getaddrinfo ENOTFOUND undefined undefined:27017

MongoError: getaddrinfo ENOTFOUND undefined undefined:27017

这是我目前的代码:

This is my current code:

var mongoose = require('mongoose');

var dbURI = "mongodb://localhost/loc8r";
if (process.env.NODE_ENV === 'production') {
    dbURI = process.env.MONGOLAB_URI;
}
mongoose.connect(dbURI);

疑难解答我从终端启动了应用程序:

Troubleshooting I started the app from the terminal with:

NODE_ENV=production MONGOLAB_URI=/*my mongo uri here*/

,它在本地运行良好。所以我不确定问题来自哪里。任何对列出的错误进行故障排除的建议?

with that it runs fine locally. So I'm not sure where the issue is coming from. Any suggestions for troubleshooting the error listed?

推荐答案

所以我不确定这个过程的哪个部分解决了问题,但我完全从Heroku中删除/删除了mongolab插件。然后我重新添加了它,并使用相同的代码执行了相同的确切步骤,并且工作正常!

So I'm not sure what part of this process fixed the issue but I completely removed/deleted the mongolab addon from Heroku. Then I added it back on and performed the same exact steps with the same code and it worked!

感谢所有帮助过我的人!

Thanks for everyone who was helping out!

这篇关于MongoError:getaddrinfo ENOTFOUND undefined undefined:27017的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆