---
title: "Fix Discord Bot Errors - Troubleshooting Guide | FPS.ms"
description: "Fix common Discord bot issues on FPS.ms: token errors, missing modules, bot going offline, and crash loops. Solutions for Python and Node.js bots."
url: https://fps.ms/docs/discord-bots/troubleshooting
---
# Troubleshooting

Running into issues with your Discord bot on FPS.ms? This guide covers the most common problems and their solutions for both Python and Node.js bots.

## Bot won't start

### "No such file or directory: app.py"

**Full error:** `/usr/local/bin/python: can't open file '/home/container/app.py': [Errno 2] No such file or directory`

**Cause:** FPS.ms looks for `app.py` as the Python entry point, but the file is missing or named differently.

**Fix:**
1. Go to the **Files** tab in the panel
2. Make sure you have a file named exactly `app.py` in the root directory (not inside a subfolder)
3. If your main file has a different name, rename it to `app.py`

### "Cannot find module" (Node.js)

**Full error:** `Error: Cannot find module 'discord.js'`

**Cause:** Dependencies are not installed, usually because `package.json` is missing or incorrect.

**Fix:**
1. Verify you have a `package.json` in the root directory
2. Make sure `discord.js` is listed under `dependencies` in your `package.json`
3. Do **not** upload the `node_modules` folder — FPS.ms runs `npm install` automatically
4. Restart your server to trigger a fresh install

### "ModuleNotFoundError" (Python)

**Full error:** `ModuleNotFoundError: No module named 'discord'`

**Cause:** The `requirements.txt` file is missing or doesn't include `discord.py`.

**Fix:**
1. Create a `requirements.txt` file in the root directory
2. Add `discord.py` (and any other packages your bot uses) to the file
3. Restart your server — FPS.ms installs packages from `requirements.txt` on startup

```txt title="requirements.txt"
discord.py
```

!!! tip "Check your imports" "Every `import` statement in your code that isn't a Python built-in needs a matching line in `requirements.txt`. For example, if you use `import aiohttp`, add `aiohttp` to the file."

## Token errors

### "TOKEN_INVALID" or "Improper token"

**Cause:** The bot token is wrong, expired, or not set.

**Fix:**
1. Open your `.env` file in the **Files** tab on the FPS.ms panel
2. Check that `BOT_TOKEN=` contains your full token with no extra spaces or line breaks
3. If in doubt, [reset your token](https://fps.ms/docs/discord-bots/getting-your-bot-token.md) in the Discord Developer Portal and paste the new one

### "Used disallowed intents"

**Full error:** `discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled`

**Cause:** Your code enables a privileged intent (Presence, Server Members, or Message Content) that isn't turned on in the Discord Developer Portal.

**Fix:**
1. Go to the [Discord Developer Portal](https://discord.com/developers/applications)
2. Select your application and click **Bot** in the sidebar
3. Scroll to **Privileged Gateway Intents**
4. Enable the intents your bot uses
5. Restart your bot on FPS.ms

See the [bot token guide](https://fps.ms/docs/discord-bots/getting-your-bot-token.md) for details on which intents you need.

## Bot goes offline

### Bot starts then immediately stops

**Cause:** Your code has an error that crashes the bot after connecting.

**Fix:**
1. Check the **Console** tab for error messages — the last few lines before it stops will tell you what went wrong
2. Common causes:
   - Missing environment variable — see [environment variables guide](https://fps.ms/docs/discord-bots/using-environment-variables.md)
   - Syntax error in your code — fix and re-upload via [SFTP](https://fps.ms/docs/getting-started/connecting-to-sftp.md) or the panel
   - Missing dependency — add it to `requirements.txt` or `package.json`

### Bot runs for a while then disconnects

**Cause:** Usually a memory limit, unhandled error, or rate limiting.

**Fix:**
1. **Memory limit:** Free servers have limited RAM. Check if your bot uses a lot of memory (large caches, storing data in memory). Consider using a database instead.
2. **Unhandled errors:** Add error handling to catch exceptions that would otherwise crash your bot:

**Python:**
```py
@bot.event
async def on_error(event, *args, **kwargs):
    print(f'Error in {event}: {args}')
```

**Node.js:**
```js
client.on('error', error => {
    console.error('Client error:', error);
});

process.on('unhandledRejection', error => {
    console.error('Unhandled rejection:', error);
});
```

3. **Rate limiting:** If your bot sends too many requests to Discord's API, it gets rate limited. Add delays between bulk operations and avoid sending messages in loops.

### Bot goes offline at the same time every day

**Cause:** Free servers need to be renewed regularly. If the server stops, so does your bot.

**Fix:**
- Check your [server renewal status](https://fps.ms/docs/getting-started/how-server-renewal-works.md) on the panel
- Set up a [schedule](https://fps.ms/docs/getting-started/creating-schedules.md) to auto-restart your bot

## Slash commands not working

### Commands not appearing

**Cause:** Commands haven't been synced with Discord, or you're using global commands (which take up to 1 hour to appear).

**Fix:**
1. For **Python (discord.py):** Make sure you call `await self.tree.sync()` in your `setup_hook()`
2. For **Node.js (discord.js):** Run your `deploy-commands.js` script
3. Try using guild-specific commands for instant registration during development

See the [slash commands guide](https://fps.ms/docs/discord-bots/adding-slash-commands.md) for full setup instructions.

### "Unknown interaction" or "Interaction failed"

**Cause:** Your bot took longer than 3 seconds to respond to a command.

**Fix:** Use deferred replies for slow operations:

**Python:**
```py
@bot.tree.command(name='slow', description='A slow command')
async def slow(interaction: discord.Interaction):
    await interaction.response.defer()
    # ... do slow work ...
    await interaction.followup.send('Done!')
```

**Node.js:**
```js
await interaction.deferReply();
// ... do slow work ...
await interaction.followup.send('Done!');
```

## Dependency issues

### Python package version conflicts

**Cause:** Two packages require different versions of the same dependency.

**Fix:** Pin specific versions in `requirements.txt`:

```txt title="requirements.txt"
discord.py==2.5.2
aiohttp==3.11.14
```

### Node.js "ERESOLVE unable to resolve dependency tree"

**Cause:** Package version conflicts in your `package.json`.

**Fix:**
1. Remove the `node_modules` folder and `package-lock.json` from your server files
2. Restart the server to trigger a fresh `npm install`
3. If the issue persists, update your `package.json` to use compatible versions

## Still need help?

If none of these solutions fix your issue:

1. Check the **Console** tab on the FPS.ms panel — error messages usually tell you exactly what's wrong
2. Join the [FPS.ms Discord server](https://fps.ms/discord) for community support
3. Review the official documentation for your bot library:
   - Python: [discord.py docs](https://discordpy.readthedocs.io/)
   - Node.js: [discord.js guide](https://discordjs.guide/)

---

[FPS.ms](https://fps.ms/index.html.md) · [All pages](https://fps.ms/llms.txt) · [Documentation](https://fps.ms/docs/llms.txt)
