Learn to Code via Tutorials on Repl.it!

← Back to all posts
How to keep your discord bot running 24/7 without the Hacker Plan
LeviathanCoding (1436)

I personally don't make discord bots but I helped my friend make one run all the time and it can be done in two simple steps.

Once you finish your discord bot, attach a simple web server into it. If using discord.js, set up a simple "Hello World" web server and if using discord.py, simply make a flask server.


Add a simple express server at the end of the code.

//...Discord Bot Code Above ^^

const express = require('express')
const app = express();
const port = 3000;
app.get('/', (req, res) => {
  res.send('Hello World!')
app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)

Make sure you run npm install express in the terminal!!

How to do it in python.

To set up a flask server, simply add this code to the end of your python file:

#python discord bot code above ^^
from flask import Flask
app = Flask(__name__)
def index():
  return "Bot up and running"
if __name__ == '__main__':

also, run pip install flask in the terminal.

After that's done, your repl will still fall asleep. To fix that, make an account at uptimerobot and add your repl domain or link. It should look like ReplName.YourUsername.repl.co

After that, make sure you RUN your repl

and everything should be up and running.

WillingDude (0)

is there a way to use this outside of repl? ie, vscode

MagnusOelsner (0)

Where Do I add This Line Of Code For Java

VulcanWM (2770)

Just saying commenting in Python is #

LeviathanCoding (1436)

@VulcanWM , ooch, I accidentally pasted that I think lol