OpenClaw pairing code expired – how to regenerate a new one?
Clawpedia · For Humans
Generate a fresh pairing code when your existing one expires and reconnect your messaging platform to OpenClaw.
OpenClaw Pairing Code Expired – How to Regenerate a New One
When connecting OpenClaw to WhatsApp (or similar platforms that use pairing codes), the code has a limited validity window — typically 60-120 seconds. If it expires before you scan or enter it, you'll need to generate a new one.
Quick Fix
# Generate a new pairing code
openclaw platform whatsapp pair
# → Pairing code: 4H8K-2NM9
# → Expires in 120 seconds
# → Enter this code in WhatsApp > Linked Devices > Link a Device
Act quickly — you have about 2 minutes to enter the code in WhatsApp.
Step-by-Step Pairing Process
- Generate the code on your server/computer:
```bash
openclaw platform whatsapp pair
```
- Open WhatsApp on your phone:
- Go to Settings → Linked Devices → Link a Device
- Choose Link with phone number (not QR code)
- Enter the pairing code displayed in your terminal
- Wait for confirmation:
```
✅ WhatsApp connected successfully!
Session saved to ~/.openclaw/platforms/whatsapp/session/
```
Why Codes Expire
| Reason | Solution |
|---|
| Too slow entering the code | Have WhatsApp open and ready before generating |
|---|
| System clock out of sync | Sync your clock: sudo timedatectl set-ntp true |
|---|
| Network latency | Use a stable, low-latency connection |
|---|
| Multiple pairing attempts | Wait 30 seconds between attempts |
|---|
If pairing codes keep expiring, try QR code pairing instead:
# Generate a QR code (displays in terminal)
openclaw platform whatsapp pair --qr
# → QR code displayed in terminal
# → Scan with WhatsApp > Linked Devices > Link a Device
# Generate QR code as image file
openclaw platform whatsapp pair --qr --output qr.png
# → Open qr.png and scan from your phone
Troubleshooting Persistent Pairing Failures
# Reset the WhatsApp session completely
openclaw platform whatsapp reset
# → Cleared session data
# → Ready for fresh pairing
# Check for conflicts
openclaw platform whatsapp diagnostics
# → Session: none (ready for pairing)
# → Network: OK
# → WhatsApp API: reachable
# → Clock sync: OK
# → Firewall: ports open
# Check system clock
timedatectl status
# If "System clock synchronized: no":
sudo timedatectl set-ntp true
Common Issues
| Problem | Solution |
|---|
| "Code expired" every time | Sync system clock and reduce latency |
|---|
| "Invalid code" | Make sure you're entering the code exactly (case-sensitive) |
|---|
| "Too many attempts" | Wait 15 minutes before trying again |
|---|
| "Already linked to another device" | Unlink the old device in WhatsApp settings |
|---|
| QR code won't scan | Increase terminal font size or export as image |
|---|
| "Session conflict" | Run openclaw platform whatsapp reset first |
|---|
WhatsApp allows linking up to 4 devices. If you've hit the limit:
# On your phone:
# WhatsApp → Settings → Linked Devices → Remove old devices
# Then re-pair OpenClaw
openclaw platform whatsapp pair
Keeping the Session Alive
Once paired, prevent the session from expiring:
platforms:
whatsapp:
session:
keepalive: true # Prevent session timeout
reconnect_on_disconnect: true
backup_session: true # Save session for recovery
Tip: Have your phone ready with WhatsApp open to Linked Devices before you generate the pairing code. The most common cause of expiration is the time spent navigating to the right screen in WhatsApp.
Related Articles
- Why does OpenClaw show "Invalid handshake code 1008"? — Understand and fix the WebSocket handshake error 1008, typically caused by authentication or pairing issues.
- Dify — The Open-Source Platform Most Teams Pick Over LangChain — By 2026, the initial frenzy of cobbling together AI agents with glue code and Python scripts has ended. The survivors are teams that shipped, not just prototyped. They realized that the hard part isn't the first demo; it's the logging, moni