Question:
How do I make my bot/bots run forever (even if my pc is off)
Alternatively check out Always On (costs 20 cents per day).
Note that âAlways onâ will experience temporarily stops, but will immediately start again afterward, whenever Replit moves resources around.
Replit stops processing a Repl after 15 minutes of inactivity.
If youâre looking for a simple (and free) solution to host your program 24/7, follow these steps:
- Host a website usign your Node.js script. You can simply add this code to your current:
const express = require('express'); // Import the express library
const app = express(); // Launch the express app
const http = require('http'); // Import the http library
const server = http.createServer(app); // Create the server
/** Replying to request at '/' */
app.get('/', (req, res) => {
res.send('Testing...');
});
server.listen(3000, () => { }); // Opening the 3000 port
Itâll host the website. View it on YOUR-REPL-NAME.YOUR-REPLIT-USERNAME.repl.co
. You should see âTestingâŚâ printed on the screen.
- Setup a cron pinging to the site. I recommend using UptimeRobot (https://uptimerobot.com/). Youâll have to sign up in case you havenât yet, then create a new monitor. Monitor type will be HTTP(s) and URL will be the url of the website.
After you successfully setup the cron, your repl should be running 24/7.
In case you need some more help, feel free to ask, Iâll try to answer as soon as possible.
If you donât want to go through the Node.js stuff, https://daki.cc/ is a good site. Itâs free and has decent performance, but inactive servers get shut down regularly- it requires constant maintenance, but not as much as if you were hosting it on your own computer and running the program nonstop. To use the site, youâll have to create an account using discord. The dashboard is https://dash.daki.cc/.
Depending on what your bot actually needs to do, you might be able to use a reverse webhook (interactions endpoint)
For instance if it just needs to do something when a user executes a command you donât need to have it connected to discord 24/7
Hello @JuriHusch! I would recommend making a url for that node.js project (if you can) and using uptimerobot to ping that url. This will keep it awake and active. Now I donât code Node JS, but I have a python discord bot that has a flask server on a url and I have uptimerobot pinging it, now sometimes the bot will be down from time to time, but still, it is a free source.
I am trying to keep my coding journey free as in I donât want to pay much for a Hacker or Pro plan, so if you want advice from along those lines, you can talk to me.
Also I am going to use this as an advertising for my discord bot! So everyone I have an AI discord bot that I need to get into 75 servers. You donât need to use it, but it has to be a member of the server. I want to verify it, and to verify it, I need 75! So if you want it, go to https://gizmo-ai-discord-bot.mileswk.repl.co/! Please yaâll, I would apriciate it. we are in 21 servers right now. Also I can take down this post if you do not like it.
you donât need to ping it if its a reserved VM, and autoscale deployments donât entirely work like that, autoscale is more likely to be used for webhooks
UptimeRobot works kinda well, I donât know haw to make it have statuses as in âPlaying With Pythonâ under the name, but there is most likely a way to have it cycle, which makes the bot have something to do, and wonât go offline
Pretty sure if you make your server ping itself every 5 minutes or so, it will stay awake (not sure about Replit, but it works on Glitch)
yeah works with glitch
not after the new deployments change tho
yea it sucks, but replit does that now.
Thank you. I have been using Uptimerobot to ping my replit for months ago but recently it hasnât been working plus the server url isnât showing anymore (i.e âŚrepl.co)
What method are you using to run your bot recently for 24/7?
Try deploying your bot as a Reserved VM if it has no web framework.
I donât have any anymore. Since the deployment change, Gizmo has been a mess and so I am having trouble with that.
You can host it for free on Cloudflare or if you want to pay (or have pro) you can host it on a reserved vm or autoscale deployment.