Back to Article List

Run OpenClaw as a systemd service with Discord and a free Qwen model

Run OpenClaw as a systemd service with Discord and a free Qwen model

Once OpenClaw is installed and connected to Discord, the next problems show up quickly. The gateway stops when the SSH session closes. The bot replies in places it shouldn’t. And paying for models feels unnecessary when free options exist.

This guide fixes all three, step by step, without changing how you installed OpenClaw. The focus is stability, control, and a clean default model using Qwen’s free tier.

If you’re not there yet, start with installing OpenClaw on Ubuntu 25.04 with Discord. Everything below assumes that setup already works.

Running the OpenClaw gateway as a systemd service

Keeping the gateway alive inside an SSH session is fine for testing. It’s annoying the moment you want uptime. systemd solves this cleanly and gives you logs, restarts, and auto-start at boot.

Creating the systemd unit file

Create a new service file on the server:

cat >/etc/systemd/system/openclaw-gateway.service <<'EOF'
[Unit]
Description=Openclaw Gateway
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
EnvironmentFile=/opt/openclaw/.env
WorkingDirectory=/root/.openclaw
ExecStart=/usr/bin/openclaw gateway --force
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload && systemctl enable --now openclaw-gateway.service

This does a few important things. It waits for networking to be fully up. It loads environment variables from /opt/openclaw/.env. And it restarts the gateway automatically if something crashes.

If your OpenClaw binary is not in /usr/bin, adjust ExecStart. You can confirm the path with:

which openclaw

Checking service status and logs

Once enabled, you should see the service running:

systemctl status openclaw-gateway.service

When debugging, this is where you’ll spend time:

journalctl -u openclaw-gateway.service -f

If you care about hardening later, moving the gateway to a non-root user is a good idea. For now, keeping parity with your existing install avoids surprises.

Creating a dedicated Discord channel for OpenClaw

By default, a Discord bot responds anywhere it has permission. That’s rarely what you want. A single channel keeps conversations readable and avoids accidental replies.

Create a new text channel on your Discord server. A name like #openclaw or #ai-bot keeps expectations clear.

[


Enabling Developer Mode and copying Discord IDs

OpenClaw binds Discord behavior using raw IDs, not names. To copy them, Discord’s Developer Mode needs to be enabled.

Turning on Developer Mode

Open Discord settings from the gear icon, then go to Advanced and enable Developer Mode.




Copying server ID and channel ID

Right-click the server icon and copy the server ID.


Then right-click the channel you created and copy the channel ID.


Keep both IDs handy. You’ll need them immediately.

Restricting OpenClaw to a single Discord server and channel

This is the part that stops accidental replies across the entire server. OpenClaw supports allowlisting at the guild and channel level.

Applying the base allowlist

Replace the placeholders with your actual IDs:

openclaw config set channels.discord.guilds '{"PASTE_GUILD_ID_HERE":{"channels":{"PASTE_CHANNEL_ID_HERE":{}}}}'

Restart the gateway so the config is reloaded:

openclaw gateway restart

If you’re running exclusively via systemd, restarting the service works too:

systemctl restart openclaw-gateway.service

This setup alone already limits responses to the chosen channel.

Connecting Qwen as a free default model

Qwen is one of the few providers offering a usable free tier via OAuth. There’s no API key to paste and no card required, which makes it a good default for Discord bots.

If you want a broader comparison later, this guide on free AI models for OpenClaw covers other options and trade-offs.

Enabling the Qwen OAuth plugin

openclaw plugins enable qwen-portal-auth
openclaw gateway restart

This enables the bundled authentication flow. Nothing is configured yet.

Logging in to Qwen

Start the device login process:

openclaw models auth login --provider qwen-portal --set-default

You’ll see a URL in the terminal. Open it in a browser, sign up or log in, and approve access.



After approval, restart the gateway:

openclaw gateway restart

Selecting the Qwen model explicitly

Set the coder model as default:

openclaw models set qwen-portal/coder-model

This model handles general chat and code well enough for most Discord use cases. Vision support is available separately if you need it later.

Making sure the Discord token is registered correctly

If your Discord channel was added earlier during onboarding, re-registering it ensures the token is present in OpenClaw’s channel config.

openclaw channels add --channel discord --token "$(awk -F= '/^DISCORD_BOT_TOKEN=/{print $2}' /opt/openclaw/.env)"

Restart once more:

openclaw gateway restart

Final behavior tuning for a dedicated channel

In a bot-only channel, requiring @mentions gets old fast. This config allows automatic replies while still keeping the allowlist strict.

openclaw config set channels.discord.guilds '{"PASTE_GUILD_ID_HERE":{"requireMention":false,"channels":{"PASTE_CHANNEL_ID_HERE":{"allow":true,"requireMention":false}}}}'

Restart the gateway one last time:

openclaw gateway restart

Verifying everything works

The bot should now appear online and reply normally in the dedicated channel.


If something feels off, start with the logs:

journalctl -u openclaw-gateway.service -f

For deeper checks, openclaw doctor --repair catches most misconfigurations.

Your idea deserves better hosting

24/7 support 30-day money-back guarantee Cancel anytime
Abonament

1 GB RAM VPS

35.93 kr Save  50 %
17.92 kr Lunar
  • 1 vCPU AMD EPYC
  • 30 GB NVMe stocare
  • Traficnecontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Firewall configurabil
  • Monitorizare server gratuit

2 GB RAM VPS

44.93 kr Save  20 %
35.93 kr Lunar
  • 2 vCPU AMD EPYC
  • 30 GB NVMe stocare
  • Traficnecontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Firewall configurabil
  • Monitorizare server gratuit

6 GB RAM VPS

125.96 kr Save  29 %
89.95 kr Lunar
  • 6 vCPU AMD EPYC
  • 70 GB NVMe stocare
  • Traficnecontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Firewall configurabil
  • Monitorizare server gratuit

AMD EPYC VPS.P1

62.94 kr Save  29 %
44.93 kr Lunar
  • 2 vCPU AMD EPYC
  • 4 GB memorie RAM
  • 40 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

AMD EPYC VPS.P2

116.96 kr Save  31 %
80.95 kr Lunar
  • 2 vCPU AMD EPYC
  • 8 GB memorie RAM
  • 80 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

AMD EPYC VPS.P4

234.01 kr Save  31 %
161.98 kr Lunar
  • 4 vCPU AMD EPYC
  • 16 GB memorie RAM
  • 160 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

AMD EPYC VPS.P5

292.54 kr Save  29 %
207.00 kr Lunar
  • 8 vCPU AMD EPYC
  • 16 GB memorie RAM
  • 180 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

AMD EPYC VPS.P6

441.10 kr Save  31 %
306.04 kr Lunar
  • 8 vCPU AMD EPYC
  • 32 GB memorie RAM
  • 200 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

AMD EPYC VPS.P7

558.15 kr Save  35 %
360.07 kr Lunar
  • 16 vCPU AMD EPYC
  • 32 GB memorie RAM
  • 240 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

EPYC Genoa VPS.G1

44.93 kr Save  20 %
35.93 kr Lunar
  • 1 vCPU AMD EPYC Gen4 AMD EPYC Genoa generația a 4-a 9xx4 la 3.25 GHz sau similar, bazat pe arhitectura Zen 4.
  • 1 GB DDR5 memorie RAM
  • 25 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

EPYC Genoa VPS.G2

89.95 kr Save  20 %
71.94 kr Lunar
  • 2 vCPU AMD EPYC Gen4 AMD EPYC Genoa generația a 4-a 9xx4 la 3.25 GHz sau similar, bazat pe arhitectura Zen 4.
  • 4 GB DDR5 memorie RAM
  • 50 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

EPYC Genoa VPS.G4

170.98 kr Save  32 %
116.96 kr Lunar
  • 4 vCPU AMD EPYC Gen4 AMD EPYC Genoa generația a 4-a 9xx4 la 3.25 GHz sau similar, bazat pe arhitectura Zen 4.
  • 8 GB DDR5 memorie RAM
  • 100 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

EPYC Genoa VPS.G5

270.03 kr Save  27 %
198.00 kr Lunar
  • 4 vCPU AMD EPYC Gen4 AMD EPYC Genoa generația a 4-a 9xx4 la 3.25 GHz sau similar, bazat pe arhitectura Zen 4.
  • 16 GB DDR5 memorie RAM
  • 150 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

EPYC Genoa VPS.G6

315.05 kr Save  23 %
243.02 kr Lunar
  • 8 vCPU AMD EPYC Gen4 AMD EPYC Genoa generația a 4-a 9xx4 la 3.25 GHz sau similar, bazat pe arhitectura Zen 4.
  • 16 GB DDR5 memorie RAM
  • 200 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

EPYC Genoa VPS.G7

522.14 kr Save  26 %
387.08 kr Lunar
  • 8 vCPU AMD EPYC Gen4 AMD EPYC Genoa generația a 4-a 9xx4 la 3.25 GHz sau similar, bazat pe arhitectura Zen 4.
  • 32 GB DDR5 memorie RAM
  • 250 GB NVMe stocare
  • Trafic necontorizat
  • IPv4 și IPv6 incluse Suportul IPv6 nu este disponibil momentan în Franța, Finlanda sau Olanda.
  • 1 Gbps rețea
  • Backup automat inclus
  • Firewall configurabil
  • Monitorizare server gratuit

FAQ

How do I know systemd is using the right OpenClaw binary?

Run which openclaw and compare it with ExecStart in the service file. They must match.

Automate faster, for less

Bring your winning ideas to life with AMD power, NVMe speed and unmetered bandwidth. Everything backed by 24/7 support, plus a 30-day refund period.