I built a Discord bot using Java and compiled it into an executable JAR file. I want to host it for free online and found Heroku which seems perfect for my needs. However, I keep getting this error when trying to deploy:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
The bot works perfectly when I run it on my local machine, but fails on Heroku. Looking at the logs, I can see my bot connects to Discord successfully:
2016-06-11T17:00:57.267 [ReadingThread] DEBUG d.b.j.utils.DiscordWebsocketAdapter - Received READY-packet!
2016-06-11T17:01:38.508 [pool-2-thread-1] DEBUG d.b.j.utils.DiscordWebsocketAdapter - Sending heartbeat
2016-06-11T17:02:22.866 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
I tried setting up my Procfile like this:
web: java $JAVA_OPTS -Dserver.port=$PORT -jar mybot.jar --host=0.0.0.0 --port=$PORT
But it still doesn’t work. I think the problem is that my Discord bot doesn’t actually need to bind to Heroku’s web port since it only connects to Discord’s servers. How can I make this work on Heroku? Should I be using a different dyno type instead of web?
You’re using the wrong dyno type. Discord bots run as background processes with persistent connections to Discord’s gateway - they’re not web apps serving HTTP requests. Heroku’s web dynos expect your app to bind to the assigned PORT within 90 seconds, that’s why you’re getting the R10 error. Your bot connects to Discord just fine but never binds to Heroku’s web port because it doesn’t need to. Switch your Procfile to use a worker dyno: worker: java -jar mybot.jar. Drop all the port-related arguments - you don’t need them for Discord bots. Worker dynos are made for long-running background processes like this. Just heads up - free Heroku accounts have limited worker dyno hours each month.
You’re right - Discord bots shouldn’t use web dynos since they don’t serve web traffic. I hit this exact issue when I first deployed my bot to Heroku. Web dynos expect apps to handle HTTP requests and bind to Heroku’s port within 90 seconds. Your bot connects to Discord’s websocket fine, but Heroku kills it because it never binds to the web port. Switch your Procfile to worker: java -jar mybot.jar and ditch the port config. Worker dynos are made for background processes that don’t need web requests. Just heads up - free Heroku accounts get 550 worker dyno hours monthly, so your bot sleeps after that unless you add payment info for another 450 hours.
yup, you got it! discord bots dont require web ports. just change to a worker dyno in ur Procfile like this: worker: java $JAVA_OPTS -jar mybot.jar. forget the port stuff. worker dynos are for background tasks, which fits ur bot perfectly.