502 bad gateway

I went to change a command on my discord bot, i now come across errors and 502 bad gateway, the command was not changed yet. I don`t know why i have came across 502 bad gateway, i think glitch is having High Ping Response. Let me know what to do! The project is on my different glitch.com account, for some reason I logged into this. Project website is here: https://discordstudios-asuna-1.glitch.me

Is your project page or the Glitch website experiencing 502 errors?

Project page. Yes why, i think mostly it is. It was recorded on 2019-08-22 19:31:36 and the downtime lasted for 11 hrs, 54 mins

It’s a problem with the project. Can you please father some logs of the project.

Ok. (node:129) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:1988

8:13 AM

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

8:13 AM

(node:129) 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: 10)

1 Like

Ah, it seems like your trying to run your HTTP server on port 1988? If so, listening on port 3000 should do the job. The error in your code is what’s most likely throwing 502 errors.

Where would I change this?

There should be a .listen(1988) in one of your .js files. (Most likely in server.js).

Ok. I will see if this is the case.

1 Like

I don`t see any. Are you sure there is another way its being like that?

It could be an NPM module causing this. What NPM modules are you using?

{
“name”: “Discord-Bot-Maker-Bot”,
“author”: “Robert Borghese”,
“main”: “bot.js”,
“version”: “1.2.9”,
“dependencies”: {
“discord.js”: “^11.5.1”,
“fstorm”: “^0.1.3”,
“jimp”: “^0.6.4”,
“replace-string”: “^3.0.0”,
“request”: “^2.88.0”,
“valid-url”: “^1.0.9”,
“express”: “^4.16.4”,
“node-cmd”: “^3.0.0”,
“node-fetch”: “^2.6.0”
},
“scripts”: {
“start”: “node bot.js”
}
}

I fixed it removing “valid-url”: “^1.0.9”, thank you for your help.

My bot works but I still get this error (node:298) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:1988

8:36 AM

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

8:36 AM

(node:298) 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: 1)

8:36 AM

(node:298) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

i get a 502 bad gateway even when my bot is online.

Ah, your using DBM. DBM causes tons of issues when hosting your bot.

It appears DBM is trying to listen on port 1988 but it’s either blocked or something else is listening on that port. Could you please run refresh in the console and see if that makes a difference.

Also, it appears you don’t have a HTTP server on port 3000 to keep Uptime Robot, etc happy. In your bot.js file could you please add this code at the top.

Make sure to add express to your package.json

const express = require("express");
var httpApp = express();
httpApp.get("/", function (req, res) { res.send("Hello, World!"); });
httpApp.listen(process.env.PORT);

Having the same issue with websocket connection to glitch also. While in the past it worked flawlessy, now connection just fails with status 502. What’s going on?

https://support.glitch.com/t/error-during-websocket-handshake-unexpected-response-code-502/10496/14

2 Likes