【问题标题】:Why can't my Mac run a server on port 1000?为什么我的 Mac 不能在 1000 端口上运行服务器?
【发布时间】:2021-04-24 07:35:11
【问题描述】:

我正在尝试使用 Express.js 运行服务器,每次尝试在端口 1000 上运行它时都会收到以下消息:

events.js:292
  throw er; // Unhandled 'error' event
  ^

Error: listen EACCES: permission denied 0.0.0.0:1000
at Server.setupListenHandle [as _listen2] (net.js:1301:21)
at listenInCluster (net.js:1366:12)
at Server.listen (net.js:1452:7)
    at Function.listen (/Users/orensayag/Documents/johnBryce/26 - 210421/hw/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/Users/orensayag/Documents/johnBryce/26 - 210421/hw/index.js:6:5)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)

在服务器实例上发出“错误”事件: 在 emitErrorNT (net.js:1345:8) 在 processTicksAndRejections (internal/process/task_queues.js:80:21) { 代码:'EACCES', 错误号:-13,

  syscall: 'listen',

地址:'0.0.0.0', 端口:1000 }

我还听说 Mac 在此端口上运行存在问题,而在 Windows 中它可以按预期运行。

为什么我的 Mac 不能在端口 1000 上运行服务器?

【问题讨论】:

标签: macos express port backend


【解决方案1】:

对于低于 1024 的端口,您需要是 root。您的访问被拒绝,因为启动该进程的用户没有 root 访问权限。

【讨论】:

  • 谢谢!你知道他们为什么会这样吗?这些端口有什么特别之处吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-28
  • 2019-12-19
  • 1970-01-01
  • 2011-05-27
  • 1970-01-01
  • 2010-09-27
  • 1970-01-01
相关资源
最近更新 更多