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
}
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!');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With