Node.js:端口80上的ECONNREFUSED [英] Node.js: ECONNREFUSED on Port 80

查看:125
本文介绍了Node.js:端口80上的ECONNREFUSED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Node.js编写了一个网络服务器。
当我尝试使用为它编写的测试器测试服务器时,只有在我用于服务器的端口不是80时,我才能成功。
我已经在netstat上检查了,并且没有其他应用程序正在使用端口80。
我在控制台上遇到的错误是:

I've written a web-server using Node.js. When I tried to test my server with the tester I've written for it, I succeed only if the port I'm using for the server is not 80. I've checked on netstat, and no other application is using port 80. The error I'm getting on the console is:

Error: connect ECONNREFUSED
  at errnoException (net.js:640:11)
  at Object.afterConnect [as oncomplete] (net.js:631:18)

在这种情况下可以做什么?

What can be done in this case?

推荐答案

您可能没有权限以普通用户(例如非root用户)的身份绑定到低于1024(包括80)的端口,请尝试使用更高编号的端口(高于1024的端口,例如8080)。

You might not have permission to bind to ports below 1024 (including 80) as a normal user (e.g. non-root), try a higher numbered port (above 1024, e.g. 8080).

根据您的目标系统,并假设您是它的管理员,则可以解决诸如因此:

Depending on your target system, and assuming you are its administrator, then you can probably work around the problem like so:


  1. 使用 须藤,s例如: sudo node ./myprogram.js

或者,以 root 用户并正常运行该程序。

Or, login as the "root" user on your system and run the program as normal.

但是,不要养成定期进行任何一种操作的习惯(直到您了解原因),它们可能会引入安全漏洞,这可能会被恶意的,有动机的人利用。

However, don't get in the habit of doing either of these on a regular basis (until you understand why), they can potentially introduce security holes which may be exploitable by malicious, motivated individuals.

这篇关于Node.js:端口80上的ECONNREFUSED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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