Can't run local server when offline or tethering with iPhone

Hi! For some reason my local server won’t start when I’m without wifi or when I’m tethering with my Iphone for internet connection.

I run a start script in my IDE (Webstorm), using npm/webpack:

    "start": "run-p start:**",
    "start:hugo": "hugo -d ../dist -s site -vw",
    "start:webpack": "webpack-dev-server --config webpack.dev.js",

Hugo seems to build, but the live server won’t start:

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo ENOTFOUND localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! victor-hugo@1.0.0 start:webpack: `webpack-dev-server --config webpack.dev.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the victor-hugo@1.0.0 start:webpack script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Martin/.npm/_logs/2019-03-03T16_29_56_804Z-debug.log
Total in 1284 ms
ERROR: "start:webpack" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! victor-hugo@1.0.0 start: `run-p start:**`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the victor-hugo@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Martin/.npm/_logs/2019-03-03T16_29_56_885Z-debug.log

Here’s from the log file:

20 error code ELIFECYCLE
21 error errno 1
22 error victor-hugo@1.0.0 start:webpack: `webpack-dev-server --config webpack.dev.js`
22 error Exit status 1
23 error Failed at the victor-hugo@1.0.0 start:webpack script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

My two questions:

  1. Does anyone know why this is happening and what I can do?
  2. Is there another way to work locally?

I prefer not push every little change to github and wait for Netlify to build to be able to see changes I’ve made.

This looks like an error with npm, not hugo.

You can verify this by running:

hugo server -d ../dist -s site -vw
2 Likes

That seems to be the case. Hugo server seems to be running, but since I’m depending on webpack site looks weird.

I read in a npm forum that running npm config get https-proxy and npm config get proxy should provide some answer. I get “null” and am not the wiser…

You were right. The problem was in my hosts file – somehow it was altered.