Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix the error "connect ECONNREFUSED"?

Tags:

node.js

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

Gives this error:

  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
}
like image 231
KSohail Avatar asked Sep 19 '25 06:09

KSohail


1 Answers

Two ways you can solve this issue.

1.You can kill port which is listening on 8085 sudo killall node

2.You can change the port number. Here's a working example:

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!');
 });
like image 79
orvi Avatar answered Sep 23 '25 05:09

orvi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!