---
title: "Deploy Discord Bot | Python Starter That Builds, discord.py 2.7"
description: "Discord bot starter that builds: current discord.py, pinned Python."
category: "Bots"
url: https://railway.com/deploy/discord-bot-or-python-starter-that-build
---

# Deploy Discord Bot | Python Starter That Builds, discord.py 2.7

Discord bot starter that builds: current discord.py, pinned Python.

**[Deploy Discord Bot | Python Starter That Builds, discord.py 2.7 on Railway](https://railway.com/template/discord-bot-or-python-starter-that-build)**

- **Creator:** Pavel Volkov's Projects
- **Category:** Bots
- **Total deploys:** 14

## Template content

### discordpy-railway-starter https://devicons.railway.com/i/discord.svg

- **Source:** ak40u/discordpy-railway-starter

## Documentation

# Deploy and Host a Discord Bot on Railway

A minimal Discord bot written with [discord.py](https://discordpy.readthedocs.io) — a working starting point you extend, rather than a demo that has to be repaired first.

## About Hosting a Discord Bot

A Discord bot is a long-running process that holds a websocket to Discord's gateway. It has no HTTP endpoint and no public URL, so hosting it means keeping a worker alive, restarting it when it dies, and giving it a token through the environment rather than the source tree. That is the whole job, and it is where a starter earns its keep: the dependency set has to still install, and the failure messages have to tell you which of the three usual mistakes you made.

## Common Use Cases

- A moderation or utility bot for your own server
- A notification bot that posts build results, alerts, or scheduled digests into a channel
- A starting point for a larger bot you intend to grow

## Dependencies for Discord Bot Hosting

- `discord.py~=2.7.1` — declared as the only direct dependency, so pip resolves the rest against the Python you actually run

### Deployment Dependencies

- [discord.py documentation](https://discordpy.readthedocs.io)
- [Discord Developer Portal](https://discord.com/developers/applications)
- [Source repository](https://github.com/ak40u/discordpy-railway-starter)

### Implementation Details

The long-standing discord.py starter on Railway freezes its entire 2022 transitive tree — `aiohttp==3.8.3`, `frozenlist==1.3.3`, `yarl==1.8.2`, `multidict==6.0.3`. None of those have wheels for Python 3.12 or newer, so pip compiles them from source, and the generated C uses CPython internals that were removed:

```
frozenlist/_frozenlist.c:8088:45: error: 'PyLongObject' has no member named 'ob_digit'
frozenlist/_frozenlist.c:7723:27: error: too few arguments to function '_PyLong_AsByteArray'
error: command '/usr/bin/gcc' failed with exit code 1
ERROR: Failed building wheel for frozenlist
```

The build dies before the bot ever runs.

This template declares only `discord.py` and pins the runtime in `.python-version`, so pip installs current wheels and a future builder upgrade cannot move the interpreter underneath you.

The other two ways a Discord bot deployment fails are handled explicitly rather than as a traceback:

- a missing `DISCORD_TOKEN` exits with a message naming the variable and where to get it
- a rejected token and a missing **Message Content** intent each print what to fix and where

## Getting Started

1. Create an application in the [Discord Developer Portal](https://discord.com/developers/applications).
2. Under **Bot**, reset the token and copy it into the `DISCORD_TOKEN` variable.
3. Under **Bot → Privileged Gateway Intents**, enable **Message Content Intent**.
4. Under **OAuth2 → URL Generator**, select the `bot` scope, grant *Send Messages*, and open the generated URL to invite it.

Send `!ping` in any channel the bot can see. Add your own commands in `main.py`.

## Why Deploy a Discord Bot on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying a Discord bot on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

## Similar templates

- [Telegram JavaScript Bot](https://railway.com/deploy/5lRkWa) — A template for Telegram bot in JavaScript using grammY
- [Cobalt Tools [Updated Aug ’26]](https://railway.com/deploy/cobalt) — Cobalt Tools [Aug ’26] (Media Downloader, Converter & Automation) Self Host
- [Telegram Gateway](https://railway.com/deploy/railway-telegram-gateway) — Multi-bot Telegram webhook gateway with real-time WebSocket event streaming

Open this page in a browser: https://railway.com/deploy/discord-bot-or-python-starter-that-build
