PageSourceSearch

https://kodari.ai/_nuxt/-8r8_BuF.js

js kodari.ai collected 2026-10-05 12:07:59 UTC 17,770 bytes, 1 lines download raw bytes

1import{d as k,S,o as D,O as A,M as m,W as P,P as I,c as f,b as e,k as H,e as a,f as n,l as i,g as o,t as d,u as y,F as g,r as T,s as x,h as B,a as c,_ as O,A as M}from"./BKfa_AG6.js";import{B as R,C as b}from"./DaIbw5Px.js";import{d as F}from"./B8LXz7L0.js";import"./CZqK_WTP.js";const j={class:"article-page"},Y={class:"article-container"},C={class:"article-nav"},E={class:"article-body"},N={class:"table-wrap"},q={class:"compare-table"},W={class:"engagement-section"},L={class:"cta-block"},K=k({__name:"how-to-host-a-discord-bot",setup(V){const w=Math.floor(S/R[0].creditsPerDay),p=x(0),h=()=>{const r=window.scrollY,t=document.documentElement.scrollHeight-window.innerHeight;p.value=t>0?r/t*100:0};D(()=>{window.addEventListener("scroll",h,{passive:!0})}),A(()=>{window.removeEventListener("scroll",h)});const v=[{q:"How do I keep my Discord bot online 24/7?",a:"Run it on a machine that never turns off, with a process manager that restarts it after crashes. That can be a Raspberry Pi at home, a VPS with pm2 or systemd, or managed bot hosting that handles it for you."},{q:"Can I host a Discord bot for free?",a:`Yes, on your own computer or on a free host, with limits. Your computer only keeps the bot online while it's on, and free hosts often cap hours or sleep idle bots. On Kodari, new accounts get ${P} free credits plus ${I} more for joining the Discord, which covers ${w} days of Basic hosting.`},{q:"How much RAM does a Discord bot need?",a:"A small bot in a few servers usually runs well in 512 MB. Bots in many large servers, music bots, and bots that keep a lot of data in memory need 1 to 2 GB."},{q:"Why does my bot go offline when I close my laptop?",a:"Because the bot is a program running on your laptop. When it stops, Discord shows the bot as offline. To keep it online, run it on a machine that stays on."},{q:"How do I update a hosted bot?",a:"Upload the changed files and restart the bot. On a VPS that means copying files and running pm2 restart or systemctl restart. On Kodari, ask the AI for the change and press Restart with latest code."}];return F("OgImageText",{title:"How to Host a Discord Bot 24/7",subtitle:"Five ways to keep your bot online, and how to fix the errors that stop it.",icon:"🤖"}),m({title:"How to Host a Discord Bot 24/7 (2026 Guide)",meta:[{name:"description",content:"Keep your Discord bot online 24/7. Your PC, a Raspberry Pi, a VPS with pm2 or systemd, free hosting, or managed hosting compared, plus fixes for the errors that stop bots from starting."},{property:"og:title",content:"How to Host a Discord Bot 24/7 | Kodari"},{property:"og:description",content:"Five ways to keep your Discord bot online, what each costs, and how to fix the errors that stop bots from starting."},{name:"twitter:card",content:"summary_large_image"}]}),m({link:[{rel:"canonical",href:"https://kodari.ai/blogs/how-to-host-a-discord-bot"}],script:[{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"Article",headline:"How to Host a Discord Bot 24/7",description:"Five ways to keep a Discord bot online 24/7, what each costs, and how to fix the errors that stop bots from starting.",author:{"@type":"Organization",name:"Kodari"},publisher:{"@type":"Organization",name:"Kodari",url:"https://kodari.ai"},datePublished:"2026-10-03",dateModified:"2026-10-03"})},{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"FAQPage",mainEntity:v.map(r=>({"@type":"Question",name:r.q,acceptedAnswer:{"@type":"Answer",text:r.a}}))})}]}),(r,t)=>{const u=O,s=B;return c(),f("div",j,[e("div",{class:"reading-progress",style:H({width:p.value+"%"})},null,4),e("div",Y,[e("nav",C,[a(s,{to:"/blogs",class:"nav-back"},{default:n(()=>[a(u,{name:"mdi:arrow-left",size:"16"}),t[0]||(t[0]=e("span",null,"All Articles",-1))]),_:1})]),t[26]||(t[26]=i('<header class="article-header" data-v-e9222f0f><div class="article-tag" data-v-e9222f0f>Discord Development</div><h1 class="article-title" data-v-e9222f0f>How to Host a Discord Bot 24/7</h1><p class="article-subtitle" data-v-e9222f0f> Your bot is only online while its code is running. Here are the five ways to keep it running, what each one costs, and how to fix the errors that stop bots from starting. </p><div class="article-meta" data-v-e9222f0f><div class="author-info" data-v-e9222f0f><div class="author-avatar" data-v-e9222f0f>K</div><div class="author-details" data-v-e9222f0f><span class="author-name" data-v-e9222f0f>Kodari Team</span><div class="meta-row" data-v-e9222f0f><span data-v-e9222f0f>Oct 3, 2026</span><span class="meta-dot" data-v-e9222f0f></span><span data-v-e9222f0f>10 min read</span></div></div></div></div></header><div class="article-hero" data-v-e9222f0f><div class="hero-visual" data-v-e9222f0f><div class="hero-code-block" data-v-e9222f0f><div class="code-header" data-v-e9222f0f><span class="code-dot red" data-v-e9222f0f></span><span class="code-dot yellow" data-v-e9222f0f></span><span class="code-dot green" data-v-e9222f0f></span><span class="code-title" data-v-e9222f0f>console</span></div><div class="code-body" data-v-e9222f0f><span class="code-cmt" data-v-e9222f0f>$ pip install -r requirements.txt</span><br data-v-e9222f0f> Successfully installed discord.py python-dotenv<br data-v-e9222f0f><span class="code-cmt" data-v-e9222f0f>$ python bot.py</span><br data-v-e9222f0f><span class="code-str" data-v-e9222f0f>Logged in as TicketBot#4821</span><br data-v-e9222f0f> Synced 6 slash commands<br data-v-e9222f0f><span class="code-kw" data-v-e9222f0f>Ready in 3 servers</span><br data-v-e9222f0f></div></div><div class="hero-caption" data-v-e9222f0f>The moment every bot is waiting for. The hard part is keeping it there when you close your laptop.</div></div></div>',2)),e("article",E,[t[18]||(t[18]=i('<p class="first-paragraph" data-v-e9222f0f> A Discord bot is a program. When it runs, it connects to Discord and shows as online. When it stops, it goes offline. That&#39;s why your bot works perfectly while you test it and disappears the moment you close your terminal, shut your laptop, or your PC goe
1s to sleep. Hosting a bot 24/7 simply means running that program somewhere that never stops. </p><p data-v-e9222f0f> There are five realistic ways to do that. They range from free and fiddly to a few dollars a month and hands off. This guide walks through each one honestly, with the commands you need, and ends with the errors that stop most bots from starting and how to fix them. </p><div class="section-divider" data-v-e9222f0f></div><h2 data-v-e9222f0f>What a Bot Needs to Stay Online</h2><p data-v-e9222f0f> Whatever you choose, a hosted bot needs the same few things: </p><ul data-v-e9222f0f><li data-v-e9222f0f><strong data-v-e9222f0f>A machine that&#39;s always on.</strong> If it sleeps, reboots for updates, or loses power, your bot goes with it.</li><li data-v-e9222f0f><strong data-v-e9222f0f>The right runtime.</strong> Python for discord.py bots, Node.js for discord.js bots, with your packages installed.</li><li data-v-e9222f0f><strong data-v-e9222f0f>Something that restarts it.</strong> Bots crash. A process manager brings yours back without you noticing.</li><li data-v-e9222f0f><strong data-v-e9222f0f>Your token, kept secret.</strong> In a .env file or an environment variable, never in the code you share.</li><li data-v-e9222f0f><strong data-v-e9222f0f>Enough memory.</strong> A small bot in a few servers usually fits comfortably in 512 MB. Music bots and bots in many large servers need more.</li><li data-v-e9222f0f><strong data-v-e9222f0f>A way to see logs.</strong> When something breaks, the console output is how you find out why.</li></ul><div class="section-divider" data-v-e9222f0f></div><h2 data-v-e9222f0f>Option 1: Your Own Computer</h2><p data-v-e9222f0f> The way everyone starts. Run <code data-v-e9222f0f>python bot.py</code> or <code data-v-e9222f0f>node bot.js</code> and your bot is online. It costs nothing and it&#39;s perfect for building and testing. </p><p data-v-e9222f0f> The catch is obvious: your bot is only online while your computer is on and the terminal is open. Sleep mode, restarts, and closing the window all take it offline. Fine for a bot only you use. Not fine for a server that relies on it. </p><div class="section-divider" data-v-e9222f0f></div><h2 data-v-e9222f0f>Option 2: A Raspberry Pi or Old PC at Home</h2><p data-v-e9222f0f> A Raspberry Pi uses very little power and can run a small bot for years. An old laptop works too. After the hardware, it&#39;s close to free. </p><p data-v-e9222f0f> You become the hosting company, though. Power cuts, router restarts, SD cards wearing out, and system updates are all on you. If you enjoy tinkering, it&#39;s a great project. If you just want the bot online, it&#39;s more work than it looks. </p><div class="section-divider" data-v-e9222f0f></div><h2 data-v-e9222f0f>Option 3: A VPS</h2><p data-v-e9222f0f> A VPS is a small server you rent by the month. You get full control and it stays on, but you set up everything yourself. The usual steps: </p><ol data-v-e9222f0f><li data-v-e9222f0f>Rent a server and connect to it with SSH.</li><li data-v-e9222f0f>Install Python or Node.js.</li><li data-v-e9222f0f>Copy your bot&#39;s files over and install its packages.</li><li data-v-e9222f0f>Put your token in a .env file on the server.</li><li data-v-e9222f0f>Run the bot with a process manager so it restarts after crashes and reboots.</li></ol><p data-v-e9222f0f> For a <strong data-v-e9222f0f>discord.js</strong> bot, pm2 is the common process manager: </p><div class="inline-code-block" data-v-e9222f0f><div class="code-label" data-v-e9222f0f>Keep a Node.js bot running with pm2</div><div class="code-content code-mono" data-v-e9222f0f> npm install -g pm2<br data-v-e9222f0f> pm2 start bot.js --name my-bot<br data-v-e9222f0f> pm2 save<br data-v-e9222f0f> pm2 startup </div></div><p data-v-e9222f0f> For a <strong data-v-e9222f0f>discord.py</strong> bot, a systemd service does the same job on most Linux servers. Save this as <code data-v-e9222f0f>/etc/systemd/system/my-bot.service</code>, then run <code data-v-e9222f0f>sudo systemctl enable --now my-bot</code>: </p><div class="inline-code-block" data-v-e9222f0f><div class="code-label" data-v-e9222f0f>A systemd service for a Python bot</div><div class="code-content code-mono" data-v-e9222f0f> [Unit]<br data-v-e9222f0f> Description=My Discord bot<br data-v-e9222f0f> After=network-online.target<br data-v-e9222f0f><br data-v-e9222f0f> [Service]<br data-v-e9222f0f> WorkingDirectory=/home/bot/my-bot<br data-v-e9222f0f> ExecStart=/usr/bin/python3 bot.py<br data-v-e9222f0f>
1 Restart=always<br data-v-e9222f0f> RestartSec=5<br data-v-e9222f0f><br data-v-e9222f0f> [Install]<br data-v-e9222f0f> WantedBy=multi-user.target </div></div><p data-v-e9222f0f> After that, every change means copying files over again and restarting. You&#39;re also responsible for security updates on the server. It works well if you&#39;re comfortable on a Linux command line. </p><div class="section-divider" data-v-e9222f0f></div><h2 data-v-e9222f0f>Option 4: Free Hosting</h2><p data-v-e9222f0f> Free hosting for Discord bots exists, and it can be fine for a hobby bot. Before you rely on it, read the limits carefully. Free plans often cap the hours you can run each month, put your bot to sleep when it&#39;s idle, share a small amount of memory between many users, or ask you to renew every few days. </p><p data-v-e9222f0f> A Discord bot that sleeps is a bot that doesn&#39;t answer commands. If your server depends on it for moderation or tickets, those limits matter more than the price. </p><div class="section-divider" data-v-e9222f0f></div><h2 data-v-e9222f0f>Option 5: Managed Bot Hosting</h2>',29)),e("p",null,[t[2]||(t[2]=o(" Managed hosting runs the server for you. You upload the bot, it stays online, and you get a panel to control it. This is what ",-1)),a(s,{to:"/discord-bot-hosting",class:"article-link"},{default:n(()=>[...t[1]||(t[1]=[o("Kodari's Discord bot hosting",-1)])]),_:1}),o(" does, from $"+d(y(b))+" a month: ",1)]),t[19]||(t[19]=e("ul",null,[e("li",null,"Your bot gets its own server, online 24/7, with Python 3.13 or Node.js 22 and your packages installed for you."),e("li",null,"A full server panel with the live console, start, stop and restart, and a file manager."),e("li",null,"A daily backup and a public URL for webhooks or a dashboard."),e("li",null,"Your token and intents are checked before anything is charged."),e("li",null,"If the bot can't start, you get the reason in plain words, and Fix with AI hands the error to the AI.")],-1)),e("p",null,[t[6]||(t[6]=o(" If you don't have a bot yet, Kodari can also write it for you from a plain English description, in ",-1)),a(s,{to:"/discord-py-bot-generator",class:"article-link"},{default:n(()=>[...t[3]||(t[3]=[o("discord.py",-1)])]),_:1}),t[7]||(t[7]=o(", ",-1)),a(s,{to:"/discord-js-bot-generator",class:"article-link"},{default:n(()=>[...t[4]||(t[4]=[o("discord.js",-1)])]),_:1}),t[8]||(t[8]=o(" or ",-1)),a(s,{to:"/discord-ts-bot-generator",class:"article-link"},{default:n(()=>[...t[5]||(t[5]=[o("TypeScript",-1)])]),_:1}),t[9]||(t[9]=o(". ",-1))]),t[20]||(t[20]=e("div",{class:"section-divider"},null,-1)),t[21]||(t[21]=e("h2",null,"Side by Side",-1)),e("div",N,[e("table",q,[t[17]||(t[17]=e("thead",null,[e("tr",null,[e("th",{scope:"col"}),e("th",{scope:"col"},"Online 24/7"),e("th",{scope:"col"},"Setup"),e("th",{scope:"col"},"Cost")])],-1)),e("tbody",null,[t[13]||(t[13]=e("tr",null,[e("th",{scope:"row"},"Your computer"),e("td",null,"Only while it's on"),e("td",null,"None"),e("td",null,"Free")],-1)),t[14]||(t[14]=e("tr",null,[e("th",{scope:"row"},"Raspberry Pi"),e("td",null,"Yes, if the power stays on"),e("td",null,"Medium"),e("td",null,"Hardware once")],-1)),t[15]||(t[15]=e("tr",null,[e("th",{scope:"row"},"VPS"),e("td",null,"Yes"),e("td",null,"High"),e("td",null,"Monthly")],-1)),t[16]||(t[16]=e("tr",null,[e("th",{scope:"row"},"Free hosting"),e("td",null,"Often limited"),e("td",null,"Low"),e("td",null,"Free")],-1)),e("tr",null,[t[10]||(t[10]=e("th",{scope:"row"},"Kodari hosting",-1)),t[11]||(t[11]=e("td",null,"Yes",-1)),t[12]||(t[12]=e("td",null,"One click",-1)),e("td",null,"From $"+d(y(b))+"/month",1)])])])]),t[22]||(t[22]=i('<div class="section-divider" data-v-e9222f0f></div><h2 data-v-e9222f0f>Why Your Bot Won&#39;t Start, and How to Fix It</h2><p data-v-e9222f0f> Most bots that fail on a new host fail for one of a handful of reasons. Here&#39;s what the error looks like and what to do. </p><h3 data-v-e9222f0f>PrivilegedIntentsRequired or &quot;Used disallowed intents&quot;</h3><p data-v-e9222f0f> Your code asks for a privileged intent, usually Message Content, Server Members or Presence, that isn&#39;t enabled for your bot. discord.py raises <code data-v-e9222f0f>PrivilegedIntentsRequired</code> and discord.js says <code data-v-e9222f0f>Used disallowed intents</code>. Open the Discord Developer Portal, pick your application, go to <strong data-v-e9222f0f>Bot</strong>, and turn the intent on under Privileged Gateway Intents. Then restart. <
1/p><h3 data-v-e9222f0f>Invalid token</h3><p data-v-e9222f0f> discord.py shows <code data-v-e9222f0f>LoginFailure: Improper token has been passed</code> and discord.js shows <code data-v-e9222f0f>An invalid token was provided</code>. The token is wrong, has extra spaces, or was reset. Reset it on the Bot page of the Developer Portal and paste the new one into your .env file. </p><h3 data-v-e9222f0f>ModuleNotFoundError or &quot;Cannot find module&quot;</h3><p data-v-e9222f0f> A package isn&#39;t installed on the host. Make sure it&#39;s listed in <code data-v-e9222f0f>requirements.txt</code> for Python or <code data-v-e9222f0f>package.json</code> for Node.js, and that the host installs them before starting the bot. </p><h3 data-v-e9222f0f>Missing Permissions or Missing Access</h3><p data-v-e9222f0f> The bot is online but can&#39;t do what it was asked in your server. Re-invite it with the permissions it needs, or give its role those permissions in Server Settings. Check the channel&#39;s own permission overrides too. </p><h3 data-v-e9222f0f>The bot is online but slash commands don&#39;t show</h3><p data-v-e9222f0f> The commands were never registered with Discord, or the bot was invited without the <code data-v-e9222f0f>applications.commands</code> scope. Make sure your code syncs its commands on start, and re-invite the bot with both the <code data-v-e9222f0f>bot</code> and <code data-v-e9222f0f>applications.commands</code> scopes. </p><div class="pull-quote" data-v-e9222f0f><p data-v-e9222f0f>Hosting a bot isn&#39;t hard. Finding out why it stopped at 3am is. Whatever you choose, make sure you can see its logs.</p></div><div class="section-divider" data-v-e9222f0f></div><h2 data-v-e9222f0f>Frequently Asked Questions</h2>',16)),(c(),f(g,null,T(v,l=>(c(),f(g,{key:l.q},[e("h3",null,d(l.q),1),e("p",null,d(l.a),1)],64))),64))]),e("div",W,[t[25]||(t[25]=i('<div class="section-divider" data-v-e9222f0f></div><div class="engagement-row" data-v-e9222f0f><div class="engagement-tags" data-v-e9222f0f><span class="eng-tag" data-v-e9222f0f>Discord</span><span class="eng-tag" data-v-e9222f0f>Hosting</span><span class="eng-tag" data-v-e9222f0f>discord.py</span><span class="eng-tag" data-v-e9222f0f>discord.js</span><span class="eng-tag" data-v-e9222f0f>VPS</span></div></div>',2)),e("div",L,[t[24]||(t[24]=e("p",{class:"cta-text"},"Want your bot online in a minute instead?",-1)),a(s,{to:"/discord-bot-hosting",class:"cta-button"},{default:n(()=>[t[23]||(t[23]=e("span",null,"See Discord Bot Hosting",-1)),a(u,{name:"mdi:arrow-right",size:"18"})]),_:1})])])])])}}}),_=M(K,[["__scopeId","data-v-e9222f0f"]]);export{_ as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.