How do i make my discord bot run 24/7?

Posted October 29, 2016 98.4k views

When i close the terminal the bot closes how do i make it not close, So it can run all night all day.


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

5 answers

You need some node module that would allow to run it forever.

I can recommend you two - pm2 or forever. I’m more on side of pm2 as it have better process management. Also there are tutorials on DO for setting it up.

Follow PM2 part of Set Up Node.js App for Production. It’ll show you how to make it run always and as a service (e.g. automatically run it when servers reboot or after power on)

by Brennen Bearnes
Node.js is an open source JavaScript runtime environment for easily building server-side and networking applications. Node.js applications can be run at the command line but this guide focuses on running them as a service using PM2, so that they will automatically restart on reboot or failure, and can safely be used in a production environment.

Instead of using PM2 or Forever… you can simply use & install SCREEN… just open a new screen, run your process… then close your terminal.

  • Would SCREEN happen to run the bot faster than forever? Because my bot is laggy at times with forever.

    • Yes, because SCREEN creates a new terminal environment and runs it there. It runs it the same as you would run it directly in the terminal. It should run just as well. I suggest trying to make it use systemd instead so it will restart, because when your server restarts (or your droplet, because this is on a Digital Ocean forum page), then the discord bot will also restart. I also suggest making your bot restart when there’s an error or your bot closes the connection, because I have found that 24/7 discord bots will at some point disconnect from discord and not reconnect.

      You said that your bot is laggy at times with forever, SCREEN shouldn’t be laggy at all.

Ugh… This did not really help me cause I use a chromebook… Is there a way to get custom bot commands using a chromebook?

Unfortunately there is now 24/7 not for discord music yet. Discord is only 2 years old and is still in development.

Hey TastyCookies, I had this problem too. If you’re trying to make the bot appear as online, you may need to connect to Discord’s sockets, which will make the dot appear and the bot will show as online. Just connecting and making REST calls isn’t enough. This is what we did with Guilded’s Discord bot (, and it came online after that. I’d personally recommend for websockets for this.

Submit an Answer