listen EADDRNOTAVAIL error in Node.js

1,753 views
Skip to first unread message

thuan le minh

unread,
May 29, 2012, 10:24:43 AM5/29/12
to nodejs
Hi all,

i installed Nginx and Node.js in my server !
i tested Nginx , it worked Ok

when i try ran my node.js file , i got an error :

node.js:201
throw e; // process.nextTick error, or 'error' event on first
tick
^
Error: listen EADDRNOTAVAIL
at errnoException (net.js:614:11)
at Array.0 (net.js:689:28)
at EventEmitter._tickCallback (node.js:192:40)


some body help me fix it ?

thank !

Ben Noordhuis

unread,
May 29, 2012, 10:29:41 AM5/29/12
to nod...@googlegroups.com
You should post your code but, at a glance, it seems you're trying to
bind to an IP address you don't actually own.

thuan le minh

unread,
May 29, 2012, 10:51:59 PM5/29/12
to nodejs
Yes Ben !
here is my nginx configuration file :
server {
listen 0.0.0.0:86;
server_name bongda.com.vn;
access_log /var/log/nginx/yourdomain.log;
........
location / {
# The IP(s) on which your node server is running , I chose the
port 3000
proxy_pass http://127.0.0.1:3001;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
}

...
and about node.js file :
var http = require('http');

http.createServer(function(req, res){
res.writeHead(200, {'Conten-type': 'text/plain'});
res.end(' ');
}).listen(3001, "127.0.0.1");


On 29 Tháng Năm, 21:29, Ben Noordhuis <i...@bnoordhuis.nl> wrote:

Ben Noordhuis

unread,
May 30, 2012, 9:01:37 AM5/30/12
to nod...@googlegroups.com
On Wed, May 30, 2012 at 4:51 AM, thuan le minh <leminh...@gmail.com> wrote:
> Yes Ben !
> here is my nginx configuration file :
> server {
>  listen 0.0.0.0:86;
>  server_name bongda.com.vn;
>  access_log /var/log/nginx/yourdomain.log;
> ........
>  location / {
>        # The IP(s) on which your node server is running , I chose the
> port 3000
>        proxy_pass      http://127.0.0.1:3001;
>        proxy_set_header X-Real-IP      $remote_addr;
>        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
>        proxy_set_header Host           $http_host;
>        proxy_set_header X-NginX-Proxy  true;
>        proxy_redirect off;
>  }
>
> ...
> and about node.js file :
> var http = require('http');
>
> http.createServer(function(req, res){
>        res.writeHead(200, {'Conten-type': 'text/plain'});
>        res.end(' ');
> }).listen(3001, "127.0.0.1");

Looks okay to me, nothing that's obviously wrong (except that
Content-Type is spelt wrong but that's inconsequential). What does
`strace node yourapp.js` print?
Reply all
Reply to author
Forward
0 new messages