Node.js web memory error "Error: listen for EADDRNOTAVAIL Error: listen for EADDRNOTAVAIL"

The app works fine on localhost. But when he connects to the server he gets an error.
I am connecting the server on port 22

This is mistake

at errnoException (net.js:904:11)
at Server._listen2 (net.js:1023:19)
at listen (net.js:1064:10)
at net.js:1146:9
at dns.js:72:18
at process._tickCallback (node.js:419:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:906:3


Any help !!!

-update -

i run netstat -tulpn | grep 22


 tcp        0      0    *               LISTEN      683/sshd
 tcp6       0      0 :::22                   :::*                    LISTEN      683/sshd


but i ran netstat -tulpn | grep 80

Nothing is displayed.

Any help. Is this a server bug?

works netstat -nlt

     Active Internet connections (only servers)
     Proto Recv-Q Send-Q Local Address           Foreign Address         State
     tcp        0      0*               LISTEN
     tcp        0      0*               LISTEN
     tcp        0      0*               LISTEN
     tcp        0      0  *               LISTEN
     tcp        0      0  *               LISTEN
     tcp        0      0    *               LISTEN
     tcp        0      0 *               LISTEN
     tcp6       0      0 :::22                   :::*                    LISTEN
     tcp6       0      0 ::1:631                 :::*                    LISTEN


Running netstat -anp | grep :80

     tcp        1      0         CLOSE_WAIT  1726/ubuntu-geoip-p
     tcp        1      0       CLOSE_WAIT  8104/epiphany-brows
     tcp        1      0         CLOSE_WAIT  1417/ubuntu-geoip-p
     tcp        1      0        CLOSE_WAIT  8104/epiphany-brows



source to share

4 answers

The port being used is in use. You must change the port, or you must kill the process that is listening on the port. Open terminal and write (example): lsof -i :22

or lsof -i :80

or lsof -i :8000

and kill PID


How can I change listening PORT in total.js?

  • in / app / config or / app / config -release or / app / config-debug:
default-ip       :
default-port     : 8000



// For e.g. Heroku
default-ip       : auto
default-port     : auto


  1. if files exist: release.js or debug.js:
var fs = require("fs");
var options = {};

// options.ip = "";
// options.port = parseInt(process.argv[2]);
options.port = 8000;


  1. if only index.js exists
// for development:
require('total.js').http('debug', { port: 8000 });

// or for production:
require('total.js').http('release', { port: 8000 });


Thanks and documentation:



I think you are using a Unix based OS, if so then you cannot use any port below 1024 without sudo access.

Also, before digging too deep, check that the listening port is not being used by any other process.

Quick fix (development only):

  • sudo node file.js

  • server.listen(3000); // any number > 1024

For production (never start node when running with root access.)

you need to map the listening port (ex: 3000) to 80 using ip tables

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000




Port 22 is reserved for ssh and in the list of known ports please

I would recommend that you run node development apps on ports 8000-9000, but you can use any of the registered ports range.



Just saw it today. User commented localhost

in his file /etc/hosts

and another network service resolved localhost

to a different IP address not associated with the user's machine.

The solution was to add this line to /etc/hosts localhost




All Articles