Ask coding questions

← Back to all posts
Repl.it File Isn't Running 24/7 Even Though I Linked Uptimerobot To It
JollyJack8 (3)

Hi there! I had just made a new discord bot using repl, and I hooked it up to uptime robot to keep it running, but the bot keeps going offline every two minutes or so, so then I have to open up the project and run it again. Is there something that I am doing wrong?

Answered by Coder100 (4007) [earned 5 cycles]
View Answer
Commentshotnewtop
Coder100 (4007)

Hello, there are other options other than uptimerobot. Try these along with it as well: mat's ping, official (beta) keeper-upper of repl.it.

Hopes this helps!

Also, be sure to mark as correct answer if it has helped you!

JollyJack8 (3)

@Coder100 Hey, in the first option, it still goes offline, and the second one keeps saying “authentication failed”.

Coder100 (4007)

hmmm... send the repl in question @JollyJack8

Coder100 (4007)

oh, nvm. Ok, so the problem is that you have no HTTP server! Http servers is what makes the bots stay alive (a terminal app shuts down after you close the tab, but a web server shuts down after 1 hour of no activity). So, just add this to your code (anywhere in the file):

const http = require("http");
http.createServer((_, res) => res.end("Alive")).listen(8080)

and your bot will work!
@JollyJack8

JollyJack8 (3)

@Coder100 so I did that, but now the commands don’t work, the bot is just idle online.

Coder100 (4007)

no no, don't replace the entire code into somewhere else!! Add the code along with the bot code @JollyJack8

JollyJack8 (3)

@Coder100 I did. I put it in server.js, and it also went offline again.

Coder100 (4007)

that's because server.js isn't run. So, just add this to index.js:

require("./server")

@JollyJack8

JollyJack8 (3)

@Coder100 omg tysm it works so well! c:

josysalt (1)

hey first change ur bots status to streaming. then it will work

JollyJack8 (3)

@josysalt I did that but it still keeps going offline. Now sometimes it’s just sitting use not responding to any commands

josysalt (1)

@JollyJack8 hmm... weird. is it js? cuz for me it works with py. ill give u template if u need.

JollyJack8 (3)

@josysalt yeah it’s js. Like, I did the stream and it says online, but if I run a command, it just stays idle and doesn’t respond. And sometimes it just goes offline altogether.