Node.js websocket 错误“错误:监听 EADDRNOTAVAIL 错误:监听 EADDRNOTAVAIL" [英] Node.js websocket error "Error: listen EADDRNOTAVAIL Error: listen EADDRNOTAVAIL"

查看:29
本文介绍了Node.js websocket 错误“错误:监听 EADDRNOTAVAIL 错误:监听 EADDRNOTAVAIL"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序在本地主机上工作正常.但是当它连接到服务器时出现错误.
我通过端口 22 连接服务器

Application work fine on localhost .but when its connect to server it getting error.
I connect server through port 22

这是错误

Error: listen EADDRNOTAVAIL Error: listen EADDRNOTAVAIL
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

任何帮助!!!

-更新-

我运行 netstat -tulpn |grep 22

结果:

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

但我运行 netstat -tulpn |grep 80

无显示.

任何帮助.这是服务器故障吗?

Any Help.is this server fault?

运行 netstat -nlt

     Active Internet connections (only servers)
     Proto Recv-Q Send-Q Local Address           Foreign Address         State
     tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN
     tcp        0      0 127.0.0.1:5901          0.0.0.0:*               LISTEN
     tcp        0      0 127.0.0.1:5902          0.0.0.0:*               LISTEN
     tcp        0      0 0.0.0.0:6001            0.0.0.0:*               LISTEN
     tcp        0      0 0.0.0.0:6002            0.0.0.0:*               LISTEN
     tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
     tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN
     tcp6       0      0 :::22                   :::*                    LISTEN
     tcp6       0      0 ::1:631                 :::*                    LISTEN

运行 netstat -anp |grep :80

     tcp        1      0 162.243.145.226:60728   91.189.94.25:80         CLOSE_WAIT  1726/ubuntu-geoip-p
     tcp        1      0 162.243.145.226:47842   74.125.239.148:80       CLOSE_WAIT  8104/epiphany-brows
     tcp        1      0 162.243.145.226:60727   91.189.94.25:80         CLOSE_WAIT  1417/ubuntu-geoip-p
     tcp        1      0 162.243.145.226:58818   198.41.30.199:80        CLOSE_WAIT  8104/epiphany-brows

推荐答案

您正在使用已使用的端口.您必须更改端口或必须终止正在侦听端口的进程.打开终端并写入(示例):lsof -i :22lsof -i :80lsof -i :8000杀死进程的PID.

You are using a used port. You must change a port or you must kill a process which is listening on a port. Open terminal and write (example): lsof -i :22 or lsof -i :80 or lsof -i :8000 and kill PID of the process.

如何更改total.js中的监听PORT?

How to change the listening PORT in total.js?

  1. /app/config/app/config-release/app/config-debug中:

default-ip       : 127.0.0.1
default-port     : 8000

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

  1. 如果存在文件:release.jsdebug.js:

var fs = require("fs");
var options = {};

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

  1. 如果只存在 index.js

// for development:
require('total.js').http('debug', { port: 8000 });

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

感谢和文档:http://docs.totaljs.com

这篇关于Node.js websocket 错误“错误:监听 EADDRNOTAVAIL 错误:监听 EADDRNOTAVAIL"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆