Skip to content

Instantly share code, notes, and snippets.

@cpsubrian
Created August 2, 2012 19:21
Show Gist options
  • Save cpsubrian/3239884 to your computer and use it in GitHub Desktop.
Save cpsubrian/3239884 to your computer and use it in GitHub Desktop.
EADDRNOTAVAIL in simple node.js web server (OSX)
$ node http.js
events.js:48
throw arguments[1]; // Unhandled 'error' event
^
Error: connect EADDRNOTAVAIL
at errnoException (net.js:670:11)
at connect (net.js:548:19)
at Socket.connect (net.js:613:5)
at Object.<anonymous> (net.js:77:12)
at new ClientRequest (http.js:1091:25)
at Object.request (http.js:1427:10)
at Object.get (http.js:1432:21)
at Object._onTimeout (/private/tmp/test.js:9:20)
at Timer.ontimeout (timers.js:94:19)
var http = require('http');
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('OK');
res.end();
}).listen(8083, function() {
var req = http.get('http://localhost:8083', function(res) {
res.on('data', function(chunk) {
console.log(chunk);
});
res.on('end', function() {
console.log('end');
});
});
req.end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment