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.
