简体   繁体   English

我收到 Nodejs 错误 EPERM:3000 的原因是什么?

[英]What can be the reason why i get an Nodejs Error EPERM: 3000?

I'm deploying my node.js ts application on ubuntu server我正在 ubuntu 服务器上部署我的 node.js ts 应用程序

app.js file listening to port 3000 app.js 文件监听 3000 端口

var port = 3000
app
    .use(authRoutes_1.default.routes())
    .use(keysRoutes_1.default.routes())
    .use(exchangesRoutes_1.default.routes())
    .use(wishlistRoutes_1.default.routes())
    .listen(port, function () {
      console.log('Listening on port ' + port);
    });

When i approach my domen through browser i get an error listen eperm 3000当我通过浏览器接近我的圆顶时,我收到一个错误监听 eperm 3000

Then i created another one simple server listener js file with the following code然后我使用以下代码创建了另一个简单的服务器侦听器 js 文件

var http = require('http');
var server = http.createServer(function(req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello World!');
});
server.listen(3000);

And suprisingly it works perfectly well令人惊讶的是,它运行得非常好

Another funny thing that running both files from ubuntu using node app.js throws the same EPERM error另一个有趣的事情是,使用 node app.js 从 ubuntu 运行这两个文件会引发相同的 EPERM 错误

How to solve this puzzle?如何解决这个难题?

It seems like port 3000 is already used by another process.似乎端口 3000 已被另一个进程使用。 Can you try something like sudo lsof -i -P -n | grep LISTEN你能试试sudo lsof -i -P -n | grep LISTEN sudo lsof -i -P -n | grep LISTEN to check if there is any other process using that port? sudo lsof -i -P -n | grep LISTEN检查是否有其他进程使用该端口? Or can you try change to another port to see if your node server works?或者您可以尝试更改到另一个端口以查看您的节点服务器是否正常工作?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM