如何修复错误“ connect ECONNREFUSED”?

时间:2019-11-08 07:34:16

标签: node.js

C:\Users\fc\Desktop\js-basics\Projects>node net.js

给出此错误:

  Error: connect ECONNREFUSED 127.0.0.1:8085
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8085
}

1 个答案:

答案 0 :(得分:0)

两种解决此问题的方法。

1。您可以杀死正在监听8085 sudo killall node的端口

2。您可以更改端口号。这是一个工作示例:

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('Hello World!'); // This will serve your request to '/'.
});

app.listen(8000, function () {
  console.log('Example app listening on port 8000!');
 });