24
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Error: getaddrinfo ENOTFOUND localhost のエラーが出た時

Posted at

Macのローカルでwebサーバーを立ち上げる時に以下のエラーが出て苦労したのでメモ
(gulpとかnpmとかyarnとか)

実行時のエラー

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

Error: getaddrinfo ENOTFOUND localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
Emitted 'error' event at:
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1507:12)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "nuxt:dev" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

解決策

というか疑う箇所。
/private/etc/hosts をテキストエディタで開いて、空だったりしたら以下を追記する

127.0.0.1   localhost

出ていたエラーは localhostが立ち上げられないよ、ってことだったみたい。

参考サイト)
javascript - gulp webserverでのエラー - スタック・オーバーフロー
Macでhostsファイルを書き換える方法 | HAZIMARU

24
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?