简体   繁体   中英

MEAN app crashed on Internet disconnection

I am developing a MEAN application. When I use localhost for local development the app is running fine on http://localhost:3300 when Internet is there but throws below error when the Internet is disconnected.

process.nextTick(function() { throw err; })
                                            ^
Error: getaddrinfo ENOENT
    at Object.exports._errnoException (util.js:746:11)
    at errnoException (dns.js:49:15)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)
    [nodemon] app crashed - waiting for file changes before starting...

Can anyone help me resolving this strange issue? As app is on localhost,it should not have any dependency on Internet. My MongoDB connection is on mongodb://localhost:27017.

Thanks!

Try changing all localhost occurrences with 127.0.0.1
Had the same problem. Turns out without an active internet connection localhost cannot be resolved into a valid IP.

Make your own local network.

I don't know the exact reason why this is happening. But I noticed that if your pc is not assigned an IP address it will produce this error.

So what I did was, I turned my portable wifi hotspot on and re-run the app and whoa! It worked! That hotspot assigned an IP address to my pc. So, it simply means you should be connected to any network. It can be your mobile hotspot too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM