LoginSignup
1
1

More than 5 years have passed since last update.

デフォルトでipv6でつながってしまう問題の回避

Posted at

node.js 0.12ではipv6がデフォルトでつながる。

何も指定しないでsv.listen(port)でサーバーをたててしまうとデフォルトでipv6になってしまうのでsv.listen(port,'0.0.0.0')を'0.0.0.0'を指定してipv4のアドレスを明示的にする

var connect = require('connect')
var bodyParser = require('body-parser')
var http = require('http')

var app = connect()
app.use(bodyParser.urlencoded({ extended: true }));
app.use(function(req, res){
  res.end('hello');
})
http.createServer(app).listen(3000, '0.0.0.0');

※参考
https://github.com/joyent/node/issues/9195

1
1
0

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
1
1