【问题标题】:How to find which port NodeJS uses?如何找到 NodeJS 使用的端口?
【发布时间】:2019-02-08 13:26:36
【问题描述】:

我试过了:

netstat -tupln 

结果如下:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:5000          0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:5001          0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:53            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:25            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:4445            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:8126          0.0.0.0:*               LISTEN      -

【问题讨论】:

  • 你只能看到哪个进程以root身份绑定了一个端口,用sudo试试那个命令。

标签: node.js linux port


【解决方案1】:

如果您有权访问您的代码,只需转到server.js 或您使用的任何文件名。那里提到了端口号。你可能会发现类似的东西

const port = process.env.APP_PORT || 80;
app.set('port', port);

const server = http.createServer(app);

【讨论】:

    猜你喜欢
    • 2011-03-26
    • 2014-08-30
    • 2011-02-10
    • 1970-01-01
    • 2020-10-08
    • 1970-01-01
    • 1970-01-01
    • 2014-01-13
    • 1970-01-01
    相关资源
    最近更新 更多