WACrew

Blog

How to host a WhatsApp bot 24/7 (VPS, Docker or Railway)

Where to run a WhatsApp bot that never stops. Why serverless doesn't work for WhatsApp Web bots, how to deploy with Docker on a VPS or a Railway template, and what you can't skip in production.

Updated 5 min read
On this page
  1. First, find out what kind of bot you have
  2. What doesn't work for WhatsApp Web bots
  3. Option 1: a VPS with Docker
  4. Option 2: Railway or another container platform
  5. Option 3: a computer of yours that stays on
  6. Comparing the options
  7. What you can't skip in production
  8. A complete example with WACrew
  9. Summary

The bot works on your laptop. You close the lid and it stops. Messages that arrive while it is off don't enter the queue, don't get answered and, depending on how it was written, don't even reach the history. That is why "where do I host this?" comes right after the first bot that works.

The answer depends on one technical detail: how your bot connects to WhatsApp.

First, find out what kind of bot you have

A bot on the official API (Meta's Cloud API). WhatsApp calls your server through a webhook when a message arrives. Your code only has to answer HTTP requests. That runs almost anywhere, serverless functions included.

A bot on WhatsApp Web (Baileys, whatsapp-web.js and similar). The bot keeps a connection open all the time, like a linked device. It needs a process that never stops and a disk that doesn't disappear, because the session is saved to files. If you use Baileys, you are in this group.

That difference rules some options out right away. Our open-source WhatsApp API comparison covers which libraries work which way.

What doesn't work for WhatsApp Web bots

Serverless (Vercel Functions or AWS Lambda). These platforms run code per request and stop the process afterwards. There is no permanent connection and no persistent disk. The bot may connect, but the connection dies when the function ends.

Shared web hosting. Built for PHP and pages, not for a Node process running all day.

Free tiers that sleep. Some platforms shut an app down after a period without traffic. For a WhatsApp Web bot, sleeping is the same as being off.

Option 1: a VPS with Docker

A VPS is a virtual server of your own, running Linux, always on. It gives you the most control and is usually the cheapest way to run something around the clock.

The simplest way to run a bot on it is Docker with a volume for the data. A minimal docker-compose.yml:

services:
  bot:
    image: your-user/your-bot:latest
    restart: unless-stopped        # comes back after a crash or a reboot
    env_file: .env
    volumes:
      - bot-data:/data             # WhatsApp session and history
    ports:
      - "3000:3000"

volumes:
  bot-data:

The two details that matter most are commented. restart: unless-stopped brings the container back after a crash or a server reboot. The volume keeps the session across image updates, so you don't scan the QR code again on every deploy.

To start it:

docker compose up -d
docker compose logs -f bot   # watch the connection and the QR code

If the bot has a web panel, put an HTTPS proxy like Caddy in front of it, and never leave the panel open without a login.

Option 2: Railway or another container platform

If you don't want to manage a server, a container platform handles the heavy lifting. On Railway, for example, you point to a Docker image or a repository, add a volume and set the variables. It takes care of restarts, a domain with HTTPS and logs.

Two things to get right:

  1. Create the volume. Without it, every deploy starts with an empty disk and the WhatsApp session is lost.
  2. Set a health check. A route that answers when the app is up lets the platform switch to a new version only once it works.

Many apps ship a ready template. WACrew, for example, has a Railway template that creates the service with the prebuilt image, a volume at /data, the panel login and a generated password.

Option 3: a computer of yours that stays on

A Mac mini, a Raspberry Pi or an old PC at home also works, as long as it stays on with a stable connection. It is a good option for testing or personal use. The weak spots are power cuts, IP changes and the work of exposing the panel safely (a tunnel such as Cloudflare Tunnel helps).

Comparing the options

VPS + DockerPlatform (Railway and similar)Computer at home
ControlFullMediumFull
MaintenanceMediumLowMedium
Persistent diskYesYes, with a volumeYes
HTTPS and domainYou set it upIncludedYou set it up
Good forProduction with several accountsGetting live fastTesting and personal use

What you can't skip in production

  1. Automatic restarts. Docker with restart, systemd or whatever the platform offers.
  2. Reconnection in your code. When the WhatsApp connection drops without a logout, the bot has to reconnect on its own. The official Baileys example does this by checking the disconnect reason.
  3. The session on a persistent disk, with a backup. Losing the auth folder means linking the device again.
  4. Logs you can read. When something breaks at night, that is how you will understand it.
  5. A login on the panel. Any web interface on the internet needs a password.
  6. An alert when it goes down. A simple monitor that calls the health route every few minutes and pings you.

A complete example with WACrew

WACrew is an open-source WhatsApp AI agent built exactly this way. The repository ships a docker-compose.yml that uses the prebuilt image ghcr.io/sumioshi/wacrew (for x86 and ARM servers), with a persistent volume and a health check. On a VPS with Docker:

git clone https://github.com/sumioshi/wacrew && cd wacrew
cp .env.example .env   # set PANEL_USER and PANEL_PASS
docker compose up -d

Then open the panel on port 3000, scan the QR code at /config and pick the groups. With the panel online, your coding agent can read and reply through the WhatsApp MCP server, from any machine.

Summary

A bot on the official API can run even on serverless. A WhatsApp Web bot needs a long-running process and a persistent disk, so the path is a VPS with Docker, a container platform with a volume, or a computer of yours that stays on. In every case, make sure you have automatic restarts, reconnection, a session backup and a login on the panel.