Node.js 端口权限在 Windows 10 中被拒绝
Node.js port permission denied in Windows 10
当我尝试在 Express.js
中启动服务器时出现此错误:
[nodemon] 2.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node main listen.js`
events.js:352
throw er; // Unhandled 'error' event
^
Error: listen EACCES: permission denied 0.0.0.0:8090
at Server.setupListenHandle [as _listen2] (net.js:1303:21)
at listenInCluster (net.js:1368:12)
at Server.listen (net.js:1454:7)
at Function.listen (C:\Users\selcuk\Desktop\work\project\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (C:\Users\selcuk\Desktop\work\project\listen.js:4:5)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1347:8)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'EACCES',
errno: -4092,
syscall: 'listen',
address: '0.0.0.0',
port: 8090
}
[nodemon] app crashed - waiting for file changes before starting...
我尝试更改端口但没有成功。
我正在使用 "express": "^4.17.1" 和 "nodemon": "^2.0.12" 作为版本。
有些情况下 运行 端口上没有任何内容,但某些应用程序甚至您的代码无法 运行。对此的修复:
- 以管理员身份打开 PowerShell。
- 停止 winnat:
net stop winnat
- 再次启动 winnat:
net start winnat
如果您是从环境变量中读取端口,请先将其转换为数字:
const httpsPort = Number(process.env.HTTPSPORT) || 3443;
当我尝试在 Express.js
中启动服务器时出现此错误:
[nodemon] 2.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node main listen.js`
events.js:352
throw er; // Unhandled 'error' event
^
Error: listen EACCES: permission denied 0.0.0.0:8090
at Server.setupListenHandle [as _listen2] (net.js:1303:21)
at listenInCluster (net.js:1368:12)
at Server.listen (net.js:1454:7)
at Function.listen (C:\Users\selcuk\Desktop\work\project\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (C:\Users\selcuk\Desktop\work\project\listen.js:4:5)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1347:8)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'EACCES',
errno: -4092,
syscall: 'listen',
address: '0.0.0.0',
port: 8090
}
[nodemon] app crashed - waiting for file changes before starting...
我尝试更改端口但没有成功。 我正在使用 "express": "^4.17.1" 和 "nodemon": "^2.0.12" 作为版本。
有些情况下 运行 端口上没有任何内容,但某些应用程序甚至您的代码无法 运行。对此的修复:
- 以管理员身份打开 PowerShell。
- 停止 winnat:
net stop winnat
- 再次启动 winnat:
net start winnat
如果您是从环境变量中读取端口,请先将其转换为数字:
const httpsPort = Number(process.env.HTTPSPORT) || 3443;