Deployment guide
A Discord bot that is still online tomorrow.
A bot has no web traffic and no request to keep it awake, which is exactly why most free hosting eventually drops it.
Bots are the workload free tiers are worst at. Platforms that sleep an idle service are measuring HTTP requests, and a bot holding a websocket open to Discord is not making any. It looks idle, it gets slept, it goes offline, and the first you hear about it is somebody in the server asking whether it is broken.
What a bot actually needs is unglamorous: a process that runs continuously, comes back by itself after a restart, and keeps its token somewhere that is not the repository.
- What it needs
- A long-running container, a restart policy, and the token stored as a secret
- Web port
- None. A bot connects out to Discord rather than accepting requests.
- Sleeping
- Nothing sleeps here — there is no idle timeout to fall foul of
- State
- A managed database, if the bot remembers anything between restarts
- Typical cost
- $5 to $12 a month of metered infrastructure for a small bot
How it goes
- Push the bot to a repositoryAny language. If there is a Dockerfile it is used; if not, Nixpacks works out the runtime.
- Create the service without a portA bot makes an outbound connection and accepts nothing, so no container port needs exposing.
- Store the token as a secretDISCORD_TOKEN as a secret environment variable — never committed, and redacted from CLI output.
- Add a database if it remembers thingsGuild settings, warning counts, economy balances. Anything the bot should still know after a restart belongs in a managed database, not on disk.
- Deploy and watch the logsThe runtime log shows the gateway connection. If the bot logs in and immediately exits, the token is usually the reason.
Why free bot hosting keeps failing
Free tiers that sleep idle services define idle as "no incoming HTTP requests". A Discord bot never receives one — it opens a websocket outward and waits. The platform sees silence and suspends it.
Some people work around this by adding a fake web server and pinging it every few minutes, which works, and is a strange amount of machinery to keep a process alive. A platform that does not sleep anything removes the problem instead of requiring a workaround.
Is free Discord bot hosting good enough?
For learning, yes. Most free bot hosts run on shared machines and suspend a bot that has been quiet, which for a personal bot in one server is often fine. What they tend not to survive is the point where the bot matters to somebody: a restart that loses state, a suspension nobody noticed for two days, no persistent storage.
The honest threshold is whether anyone would complain if the bot were offline for a morning. Below that, free hosting is the right answer and paying is a waste. Above it, the thing you are buying is not speed but the absence of surprises -- a process that stays up, a database that survives a restart, and logs that exist when you go looking.
What a bot actually costs to run
A Discord bot is a small process that mostly waits. Half a core and 512 MB covers the great majority of them, which is roughly $15 a month of metered compute and memory -- and less when it idles, because metering charges for what runs rather than what is reserved.
Add a managed Postgres if the bot remembers anything between restarts, which most useful bots do: another few dollars for a small instance plus $0.10 per GB-month of storage. On the free plan the $10 of signup credit covers a small bot for most of a month, and the plan does not sleep.
Other guides in this section
- Deploy n8nDeploy n8n so workflows and credentials survive a restart: managed Postgres, a persistent volume, and the key that breaks it.
- Deploy GhostSelf-host Ghost with managed MySQL, a persistent volume for uploaded images and a custom domain with TLS. What it costs a month.
Read next
- Environment variables and secretsEnvironment variables and secrets on Dockup: set, import, mask, rotate, and redeploy configuration safely for services and autonomous agents.
- The managed PostgreSQL guideManaged PostgreSQL on Dockup: create a database, connect a service securely, inspect size and logs, back up data, restore safely, and add read-only users.
- Reading build and runtime logsBuild and runtime logs on Dockup: use --build and --follow, separate failure stages, read NDJSON, preserve exit codes, and diagnose deploys faster.
Questions this page gets asked
How much does it cost to host a Discord bot?
A small bot is roughly $5 to $12 a month of metered infrastructure. The free plan grants $10 of credit at signup, which is enough to run one for a while before deciding anything.
Will the bot go offline when nobody uses it?
No. Nothing sleeps here, so a bot holding a gateway connection stays connected regardless of how quiet the server is.
Where do I put the bot token?
As a secret environment variable, never in the repository. Secrets are redacted from CLI output, so a shared terminal transcript is not a leaked token.
Does a bot need a web port?
No. It connects out to Discord rather than accepting incoming requests, so the service needs no exposed port at all.
Start on the free plan.
Ten dollars of infrastructure credit is already there, and no card is required.
