DEV Community


Posted on • Updated on

Hosting a Bot with

I know that hosting a discord bot with isn't very conventional. I've gotten multiple remarks about hosting it there. But I didn't really have any alternative ways of hosting a bot there.

However, hosting a python discord bot with was quite hard. I had scraped the internet for quite some time before finding a solution.

I just had to make a keep alive script and use Uptime Robot.

The keep alive script is very simple and isn't very long. You just need to include flask in requirements.txt and use threads.

from flask import Flask
from threading import Thread

app = Flask('')

def home():
    return "Bot is online"

def run():'',port=8080)

def keep_alive():  
    t = Thread(target=run)

Then on your main python file, import the keep_alive() function. Then, right before you run your bot, include keep_alive().

This code, in summary, makes a website that just says "Bot is online"

However, doesn't keep this code on 24/7. You need to make a GET request to this site every so often for it to run constantly. This is where Uptime Robot comes in.

Go to and sign up with a free plan. Then create a monitor by clicking the button.

You should see a screen like this:

For monitor type, put Http(s). Put whatever unique name you want in Friendly Name. For URL (or IP) you want to put the URL that the flask shows up on. Once you run the discord bot on repl, a box appears on the top-right of the interface with the URL.

That's it! It's done. Just click run on and you can close the tab. It works!

If you have any questions, let me know :D

Top comments (1)

spikxy profile image

its showing status up but my bot is still offline :(