如何找到哪个端口使用的NodeJS?
我试着用:
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 -
回答如下:
如果你有你的代码的访问,只要到server.js
或任何文件名已使用。端口号有提及。您可能会发现类似的东西
const port = process.env.APP_PORT || 80;
app.set('port', port);
const server = http.createServer(app);