8

Can anyone tell me why my server address (host) is :: and not 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);
});

This returns

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

It works fine when I go to http://localhost:3000/

Davetherave2010
  • 370
  • 3
  • 9

1 Answers1

5

Because :: is localhost when using IPv6, just like it is 127.0.0.1 in IPv4.

idstam
  • 2,848
  • 1
  • 21
  • 30