# A bot or app crashes right after deploy: the six usual causes

> What to read in the console when a bot exits on start, and the fixes for missing modules, wrong entry files, wrong Node or Python versions, bad tokens, ports and case-sensitive paths.

Source: https://fadehost.com/docs/bot-crashes-on-start/

The deploy finished, the console shows a few lines, and the bot is stopped again. The last lines before the exit say why, and the crash doctor on the app's page explains them in plain words. These are the six causes behind almost every failed first start.

## 1. A module is missing

`ModuleNotFoundError: No module named 'discord'` or `Error: Cannot find module 'discord.js'`.

The dependency is not in `requirements.txt` or `package.json`. Add it with the version you tested, commit, push. Installing it on your own machine does not install it here; only the repository's files do.

## 2. The entry file is not where the runtime looks

Python starts `bot.py` or `main.py`; Node.js runs the `start` script in `package.json`, or the entry file when there is none. A repository whose main file is `src/index.js` or `app.py` needs a **Start command** on the app's page: `node src/index.js`, `python app.py`, `python -m mybot`.

## 3. The wrong language was detected, or the wrong version

A repository with both `package.json` and `requirements.txt` is read as Node.js. Set **Language** on the app's page when the guess is wrong.

`SyntaxError` on a valid file usually means a version gap: code written for Node 22 running on an older runtime, or Python 3.12 syntax in a project that pins 3.9. Pin the version the code needs in `package.json` (`"engines"`) or `pyproject.toml`, and the runtime follows it.

## 4. The token or a variable is missing

`KeyError: 'DISCORD_TOKEN'`, `TypeError: Cannot read properties of undefined`, or a login failure. The code reads an environment variable that is not set, or is set under another name. Open **Environment**, compare the names with the code, save. Values from a `.env` file on your machine are not in the repository and must be entered here.

## 5. The app binds the wrong address or port

`EADDRINUSE` or a web app that starts but never answers: it listens on `127.0.0.1` or a fixed port. Listen on `0.0.0.0` and the `PORT` variable, 8080 by default. A bot with no web server can ignore ports entirely; remove any keep-alive web server left over from another host.

## 6. A path with the wrong case

`Cannot find module './Commands/ping'` when the folder is `commands`. Windows and macOS forgive case; Linux does not. Match the case in the code to the file names.

## Reading the console

The console keeps the last session of a crashed app, so the error is there even after the restart. A bot that exits with code 0 and no error simply finished: something in the code returned instead of running forever, often a missing `bot.run()` or `client.login()` call.

When the lines do not make sense, open a ticket with the app's name; the console is visible to support and the answer is usually one of the six above.
