MacOS「localhost:8080」問題
By on Sep 3, 2018
MacOSであらゆる8080が表示されない
$ curl localhost:8080
curl: (52) Empty reply from server
$ curl 127.0.0.1:8080
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>frontend</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
<script type="text/javascript" src="/app.js"></script></body>
</html>
- ESETが悪さをしてるという可能性もあるそう?
ESETを一時的に終了したが、改善せず。。。。
とりあえず、8081に変更してVue.jsを実行する。
$ PORT=8081 yarn run dev
詳細を調べてみるとhostsの設定だった
hostsの設定
IPv6 指定がlocalhostに割り当てられているのが原因
$ cat /etc/hosts 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost
hostsの編集
原因箇所をコメントアウトする
$ sudo vi /etc/hosts 127.0.0.1 localhost 255.255.255.255 broadcasthost # コメントアウト # ::1
動作確認
$ curl -v localhost:8080
* Rebuilt URL to: localhost:8080/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Accept-Ranges: bytes
< Content-Type: text/html; charset=UTF-8
< Content-Length: 324
< ETag: W/"144-+Koybw7A2IzbrCsGVT8Z3o3UXFk"
< Vary: Accept-Encoding
< Date: Tue, 04 Sep 2018 18:18:34 GMT
< Connection: keep-alive
<
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>frontend</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
<script type="text/javascript" src="/app.js"></script></body>
</html>
* Connection #0 to host localhost left intact