Keeping Replit Script Alive 24/7 with Uptime Robot
Do you have a Replit script that you want to keep running all the time? Replit has some limitations on the duration a script can run, but we can overcome this by using Uptime Robot. Uptime Robot is a simple yet powerful service that pings your script at regular intervals, preventing it from going to sleep. Let's set it up!
Step 1: Flask Keep Alive Script
First, create a Flask script that will serve as your keep-alive mechanism. Save the following code in a file named keep_alive.py:
from flask import Flask, render_template
from threading import Thread
app = Flask(__name__)
@app.route('/')
def index():
return "Alive Bot By Rehan @TekyRex"
def run():
app.run(host='0.0.0.0', port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
Step 2: Main Script
Now, in your main script (e.g., main.py), import the keep_alive function and call it to start the Flask app on a separate thread:
from keep_alive import keep_alive
keep_alive()
Step 3: Deploy to Replit
Upload both scripts to your Replit project. Run main.py, and you should see your Flask app running on https://your-replit-project-name.your-username.repl.co/.
Step 4: Uptime Robot Configuration
Go to Uptime Robot and create an account if you don't have one. Add a new monitor with the following settings:
- Monitor Type: HTTP(s)
- Friendly Name: Choose a name for your monitor
- URL (or IP): Enter your Replit project URL
- Monitoring Interval: Every 5 minutes
Save your monitor, and Uptime Robot will periodically ping your Replit script, keeping it alive 24/7!
Now, you have successfully set up a mechanism to prevent your Replit script from going to sleep. Enjoy uninterrupted running of your script!

0 Comments