(SOLVED) Getting an error every 5 minutes (ECONNREFUSED 127.0.0.1:1998)


#1

Hello! I’ve spent last 2 weeks creating a new discord bot, and I am getting this error:

(node:7091) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:1988

10:06 AM

at Object._errnoException (util.js:992:11)

10:06 AM

at _exceptionWithHostPort (util.js:1014:20)

10:06 AM

at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)

10:06 AM

(node:7091) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 29)

Any idea what the problem is? (I am new to node.js and server-side scripting so I have no idea what that error message is) Any help would be appreciated :slight_smile:


#2

You’re only able to use one port for one thing at a time, so you can get an ECONNREFUSED error when trying to start something else using the already-in-use port (we recommend you use port 3000). It’s difficult to know what specifically might be causing it without seeing the code. Let us know the project name and we’ll take a look. If your project is private, either make it public temporarily or DM me a join link so we can view the code. Thanks.


#3

Hello! Thanks for taking your time to answer on my problem :blush:
If you mean on the code in ‘server.js’ it is this one (actually I haven’t changed anything because I, as stated above, don’t know a lot about server side stuff so I didn’t want to break something):

// server.js
// where your node app starts

// init project
var express = require(‘express’);
var app = express();

// we’ve started you off with Express,
// but feel free to use whatever libs or frameworks you’d like through package.json.

// http://expressjs.com/en/starter/static-files.html
app.use(express.static(‘public’));

// http://expressjs.com/en/starter/basic-routing.html
app.get(’/’, function(request, response) {
response.sendFile(__dirname + ‘/views/index.html’);
});

// listen for requests :slight_smile:
var listener = app.listen(process.env.PORT, function () { // env.port = 3000
console.log('Your app is listening on port ’ + listener.address().port);
});


#4

Thanks. We need to see the code in full, not just snippets, which is why I asked for the project name. Please let us know the project name and we’ll take a look. If your project is private, either make it public temporarily or DM me a join link so we can view the code.


#5

Oh I see, the project name is: ice-sbot
Also, sorry for that spaghetti code I hope that you’ll be able to understand it.


#6

The port 1988 error comes from you having the debugger enabled - turn it off if you’re not using it (click the red stop sign icon in the Logs panel).

You aren’t using the server.js file in your project so you may as well delete it. Add the following to the top of index.js

const express = require('express');
const app = express();
 
app.get("/", (request, response) => {
  response.sendStatus(200);
});
app.listen(process.env.PORT);

This will stop the persistent loading.

Let me know if the problem persists.


#7

It seems that there is no problem anymore, I really appreciate your help! Have a nice day!!! :smiley: