Skip to main content
Discord bot errors on Square Cloud usually trace back to the token, the gateway intents, or a version mismatch with Lavalink. Match the exact message below.

”LoginFailure: Improper token has been passed” / TokenInvalid

What it means: Discord rejected the token your bot logs in with. The exact message depends on the library:
  • discord.py: discord.errors.LoginFailure: Improper token has been passed.
  • discord.js v14: Error [TokenInvalid]: An invalid token was provided.
  • older discord.js: Error [TOKEN_INVALID]: An invalid token was provided.
  • other libraries: an HTTP 401 Unauthorized on login.
Why it happens:
  • The token was regenerated or revoked in the Discord Developer Portal. Generating a new token instantly invalidates the old one everywhere it’s used.
  • The token string has extra spaces or quotes copied in by accident.
  • The code is reading the wrong environment variable, or the variable isn’t set on Square Cloud.
How to fix:
  1. Go to the Developer Portal → your application → Bot → Reset Token.
  2. Update the token in the application’s environment variables (dashboard Settings → Environment Variables, or squarecloud app env set). Never commit the token in a file that gets uploaded in the zip.
  3. Double-check there are no stray spaces or quotes around the value.
  4. Update the library (discord.js@latest or pip install -U discord.py).
  5. Restart the application, so it loads the new value.
Never hardcode your bot token in source files. Always read it from an environment variable set in the dashboard.

”Used disallowed intents” / Message Content Intent

What it means: the bot logs in and appears online, but ignores every message, or the gateway rejects the connection with “used disallowed intents”. Why it happens: since 2022, Message Content is a privileged intent. Without it explicitly enabled in both places, message content arrives empty (or the gateway connection is refused if your code declares an intent that isn’t enabled for the app). How to fix, in both places:
  1. Discord Developer Portal → your application → Bot → Privileged Gateway Intents → enable Message Content Intent.
  2. Declare it in code as well:
  1. Restart the application.
Once a bot passes 100 servers, privileged intents (including Message Content) also require approval from Discord, requested from the same Developer Portal page.
What it means: the bot’s Lavalink client closes the WebSocket abnormally with code 1006, often preceded by “Unexpected server response: 400”. Why it happens: this is a version mismatch. Lavalink v4 is REST-based and is incompatible with a client wrapper built for v3, so the handshake fails and the socket closes with 1006. How to fix:
  1. Align your bot’s Lavalink client wrapper version with the Lavalink server’s major version (v3 client with v3 server, v4 client with v4 server).
  2. On Square Cloud, the Lavalink server itself binds port 80, but your bot must connect to it through the edge on port 443 with secure: true.
  3. Restart both the Lavalink application and the bot application after fixing the version mismatch.
For the full Lavalink hosting setup (config file, port, deployment), see the Lavalink server tutorial.

Bot goes offline after working locally

What it means: the bot logs in fine when you run it on your machine, but goes offline (or restarts repeatedly) once deployed. Why it happens, most commonly:
  • An unstable connection at the gateway level with no reconnect handling.
  • Conflicting or incompatible dependency versions between what you tested locally and what’s in your dependencies file.
  • The bot was stopped for going over its RAM or CPU, or for flooding the Discord API. In that case the logs show a [SQUARE-SHIELD] line and you get an email: see the status table.
How to fix:
  1. Check the application’s logs in the dashboard first, they show the actual crash reason.
  2. Add error handlers so a transient error doesn’t crash the process: process.on("unhandledRejection", ...) and client.on("error", ...) in discord.js, equivalent handling in discord.py.
  3. Add AUTORESTART=true to your squarecloud.app so Square Cloud restarts the bot after a crash. It’s off by default, and it only restarts in the cases listed in AUTORESTART. It keeps the bot alive through transient errors, but it never fixes an invalid token, a syntax error or a missing dependency: those still need a fix in the code.
  4. Watch for Discord API rate limits (429): the global limit is about 50 requests/second per bot token, with tighter per-route buckets (channel create/edit allows roughly 2 changes per 10 minutes per channel). Cache aggressively, use an async queue that respects the X-RateLimit-Remaining/X-RateLimit-Reset-After headers, and use webhooks for mass sends. A bot that keeps flooding Discord is stopped with ABUSE_REQUESTS.
If the logs don’t point to a clear cause, our support team can help you dig further.

Contact us

If you continue facing technical difficulties, our specialized support team is available to assist you. Contact us and we’ll be happy to help you resolve any issue: support quality is a big part of why developers rate Square Cloud 4.9/5 across 402 reviews on Google and Trustpilot.