A
A
Ayan Bai2016-03-19 15:17:02
JavaScript
Ayan Bai, 2016-03-19 15:17:02

When the Internet is disconnected, I can not connect via nodejs to mongodb. Where is the mistake?

I connect through the console without any problems, but when I start the application it gives an error:

Error Connecting to database: { [MongoError: getaddrinfo ENOENT localhost:27017]
  name: 'MongoError',
  message: 'getaddrinfo ENOENT localhost:27017' }

Monoga connection string:
db: 'mongodb://' + (process.env.DB_PORT_27017_TCP_ADDR || 'localhost') + '/mean-dev',

Interestingly, when there is Internet on the computer, the node connects, and when I disconnect, it gives the error above.
Here is what I get when I start mongo without internet:
jEUY4L9.png
And here is what I get when I start mongo with internet:
07vSCCZ.png
WTF ? Why doesn't it work without internet?
I have everything offline. I use full stack
mean.io

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-03-19
@wolf47

message: 'getaddrinfo ENOENT localhost:27017'
"Can't get DNS for localhost domain - no internet."
In theory, for a localhost, there should be no recourse to DNS. Apparently, it is not registered in your hosts.
Change localhost to 127.0.0.1 and it should work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question