【问题标题】:Express.js- Why is Localhost '::'Express.js- 为什么是 localhost '::'
【发布时间】:2015-10-16 04:25:59
【问题描述】:

谁能告诉我为什么我的服务器地址(主机)是 :: 而不是 localhost

var express = require('express');
var app = express();

// respond with "hello world" when a GET request is made to the homepage
app.get('/', function(req, res) {
  res.send('hello world');
});

var server = app.listen(3000, function () {
  var host = server.address().address;
  var port = server.address().port;
  console.log('Example app listening at http://%s:%s', host, port);
});

返回

Example app listening at http://:::3000

当我转到http://localhost:3000/时它工作正常

【问题讨论】:

    标签: node.js express localhost


    【解决方案1】:

    因为 :: 在使用 IPv6 时是 localhost,就像在 IPv4 中是 127.0.0.1。

    【讨论】:

    猜你喜欢
    • 2022-01-23
    • 1970-01-01
    • 2021-08-06
    • 2019-05-26
    • 2021-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-14
    相关资源
    最近更新 更多