Move Your Discord Bot Off Your Home PC

How-toBy discordbothostUpdated 2 min read

The short answer: Move the project, dependencies and persistent data to a bot host, set its token as a private environment variable and start the remote process. Stop the old copy on your computer before testing commands. The bot can then keep running while your PC is off. Keep a recovery copy and check the first startup log.

Why move

Your PC sleeps, reboots for updates, and drops Wi-Fi. Each of those takes the bot offline (common causes). A host keeps the process running in a data center and restarts it if it crashes.

Step by step

  1. List dependencies. Node: package.json and lockfile. Python: pip freeze > requirements.txt, then trim it. Java: build a fat jar.
  2. Remove secrets from code. Swap the hard-coded token for process.env.BOT_TOKEN / os.environ["BOT_TOKEN"]. Do the same for API keys.
  3. Fix paths. Swap C:\Users\... for relative paths such as ./data/db.sqlite.
  4. Bring your data. Include SQLite or JSON data files in the upload. If they change a lot, think about a hosted database (discordbothost Pro includes 1).
  5. Upload and configure. Create the server from the discord.js, discord.py or JDA template. Upload a zip or use SFTP (or a public GitHub repo on Free and paid plans), set the environment variables, and press Start.
  6. Switch off the PC copy. Two running copies with the same token both answer commands, so stop the local one once the hosted bot shows "logged in".

Checklist after moving

  • The console shows your ready or "logged in" line.
  • A slash command works in your test server.
  • The memory graph stays well under the plan limit.
  • Free plan: you know your renewal day. discordbothost reminds you 48 and 24 hours before.

Why discordbothost for your first move

  • A free 256 MB plan with no idle sleep. Renew once a week.
  • Templates for the three big libraries, so there's nothing to install.
  • File manager and SFTP for uploads, plus a live console.
  • Upgrade to Starter ($0.99/month, 512 MB) for no renewal, backup slots when available and push-to-deploy.

Backups are available: manual on Free, daily and manual on paid plans.

Questions

Can I keep my Discord bot running when my PC is off?

Not on the PC itself. Move the bot to a host or server; it then runs independently of your computer.

Will my bot's data move with it?

Only what you upload. Copy any local database files (like SQLite) and config with the code, or move data into a hosted database.

Do I need to change my code to move hosts?

Usually only how the token and paths are read: use environment variables for secrets and relative paths for files.

  1. 1https://discordbothost.com/pricing/

Related