Run Python Bots Without Sleep On Render With StayPresent
Deploy Python Bots on Render Without Sleep Using StayPresent Render is one of the most popular free hosting platforms for small Python projects, but it comes with a well-known catch: free-tier web services spin down after a period of inactivity and require a fresh incoming request to wake back up. For a render python bot — a Discord bot, Telegram bot, or scraper — that "wake up" delay can mean minutes of downtime every time the service goes idle. This guide covers exactly how Render's sleep behavior works, and how to eliminate it using StayPresent . Table of Contents Understanding Render's Free Tier Why HTTP Port Requirements Matter Setting Up StayPresent for Render Health Checks Explained Self-Ping to Avoid Idle Sleep Crash Recovery on Render Full Working Example Best Practices Common Mistakes FAQs Conclusion Understanding Render's Free Tier Render's free web services sleep after roughly 15 minutes without incoming HTTP traffic. Once asleep, the next request has to spin the container back up before it responds, so real users (or a bot's own polling loop) experience a delay. Render also expects your web service to bind to a port it provides via the PORT environment variable — if nothing is listening there, Render's own health checks will consider the deploy unhealthy. [Render Health Check] --HTTP GET--> [Your Service on $PORT] | No response = unhealthy Why HTTP Port Requirements Matter A typical Telegram or Discord bot doesn't open an HTTP port — it just connects outward to Telegram's or Discord's API and waits for events. That's perfectly normal bot behavior, but it fails Render's expectations for a web service. The fix isn't to change how your bot works; it's to run a small HTTP server next to it, purely so Render has something to check. Setting Up StayPresent for Render Install the production extra so Waitress serves the app instead of Flask's development server: pip install staypresent[prod] Then in your entry point (commonly main.py ): import os import staypres