> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hyzecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# My Discord bot stops when I close the terminal

> Does your Discord bot stop when you close the terminal or turn off your PC? Learn why it happens and the options to keep your bot online 24/7.

You run `node index.js` or `python bot.py`, the bot comes online and, as soon as you close the terminal, it disappears from the server. Nothing is wrong with your code. The problem is where the bot is running.

## Why the bot stops

The bot is a process, and that process depends on two things you turn off without noticing:

* **The terminal.** The process starts as a child of the terminal. Closing the window ends the session, and the system ends the session's processes with it. The bot goes away at the same moment.
* **The computer.** If the PC shuts down, sleeps, restarts for an update or loses its internet connection, the bot goes down with it.

In other words: as long as the bot runs on your machine, it is only online while your machine is on, connected and has that terminal open.

## Options to keep the bot online

### Leave your PC on

Good enough for testing. It costs nothing beyond electricity. But the bot goes down when the power goes out, when the internet drops or when the system restarts to update. You also need to remember to open the terminal again after every outage.

### Rent a VPS and use pm2

A VPS is a Linux server that is always on. [pm2](https://pm2.keymetrics.io/) keeps the bot running after you log out of SSH and restarts it if it crashes:

```bash theme={"system"}
npm install -g pm2
pm2 start index.js --name my-bot            # discord.js
pm2 start bot.py --name my-bot --interpreter python3   # discord.py
pm2 save
pm2 startup   # prints the command that starts pm2 with the server
```

You get full control of the machine. In exchange, you handle everything: system updates, installing Node or Python, firewall setup and figuring out why something stopped.

### Use managed hosting

You upload the code, add the token, and the platform runs the process, shows the logs and restarts the bot when it crashes. There is no server to manage. In exchange, you do not touch the machine's operating system.

| Option | Cost | Who manages the machine | When the bot crashes |
| - | - | - | - |
| PC left on | Electricity | You | You open the terminal again |
| VPS with pm2 | VPS monthly fee | You | pm2 restarts it |
| Managed hosting | Plan monthly fee | The platform | The platform restarts it |

## The short path: Hyze Cloud

On Hyze Cloud there is nothing to install. It takes three steps:

1. Upload the code from GitHub or as a ZIP.
2. Add `DISCORD_TOKEN` to the environment variables.
3. Click **Deploy application** and follow the logs.

Hyze recognizes discord.js and discord.py, starts the bot without asking for a port and restarts the process if it crashes. The full walkthrough, with code samples, is in [How to keep your Discord bot online 24/7](https://docs.hyzecloud.app/en/guides/discord-bot-24h.md).

Every sign-up gets a 7-day trial. After that, the Starter plan costs R\$ 5.99 per month, paid in Brazilian reais via Pix.

## Does free hosting sleep?

Many free plans turn the app off after a while without HTTP traffic, and since a Discord bot receives no HTTP traffic, it sleeps and goes offline; on Hyze Cloud, apps are not turned off for being idle.

## Next steps

> **[Bot online 24/7](https://docs.hyzecloud.app/en/guides/discord-bot-24h.md)**
>
> Prepare the code, store the token and deploy.

> **[Open the dashboard](https://hyzecloud.com/en-us/dashboard)**
>
> Create your account and get a 7-day trial.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.