$ waitForConnection()
Troubleshooting

WhatsApp Stuck at 'Logging In': Connection Issues and Fixes

Solve the frustrating WhatsApp linking issue where QR code scans successfully but gets stuck at 'logging in'. Learn about connection timeouts, re-linking problems, and the pairing code workaround.

OT
OPENCLAW.EXPERT TEAM
|JAN 18, 2025|6 MIN READ

The Problem

You scan the WhatsApp QR code successfully, but the connection gets stuck at "logging in" and never completes. This is one of the most reported issues in the OpenClaw community.

Why This Happens

Connection Timeout Issue

The waitForWaConnection() function waits for a WhatsApp socket to reach "open" or "close" state, but has no timeout. If the connection enters an intermediate state (perpetual reconnecting, limbo), the promise hangs forever.

Symptoms:

  • QR code scans successfully

  • Status shows "logging in" indefinitely

  • No error messages in logs

  • Gateway appears frozen
  • Competing Sessions

    If you previously linked a different number and are trying to switch:

  • Old credentials may be conflicting

  • WhatsApp thinks another session is active

  • The linking process can't complete
  • Solutions

    Solution 1: Clear WhatsApp Credentials

    # Stop the gateway
    openclaw gateway stop

    # Remove WhatsApp credentials
    rm -rf ~/.openclaw/credentials/whatsapp

    # Restart and try again
    openclaw gateway start
    openclaw channels login whatsapp

    Solution 2: Use Pairing Code Method

    Instead of QR code scanning, use the phone number pairing method:

    openclaw channels login whatsapp --method pairing-code

    This generates a 6-digit code you enter in WhatsApp's "Link with phone number" option.

    Solution 3: Check Network Connectivity

    Ensure your network allows WebSocket connections:

    # Test WhatsApp connectivity
    curl -I https://web.whatsapp.com

    Some networks block WhatsApp WebSocket traffic. Try:

  • Using a mobile hotspot

  • Disabling VPN

  • Checking firewall rules
  • Solution 4: Verbose Logging

    Enable detailed logging to diagnose the issue:

    openclaw channels login whatsapp --verbose

    Look for:

  • Connection state changes

  • Authentication errors

  • Network timeouts
  • Prevention Tips

  • Don't switch numbers frequently - Each switch requires clean credentials

  • Use dedicated number - Avoids conflicts with personal WhatsApp

  • Monitor connection health - Run openclaw channels status --probe regularly

  • Keep gateway updated - Bug fixes are released frequently
  • Still Stuck?

    If the connection continues to hang, contact our team for hands-on troubleshooting assistance.

    Need Professional OpenClaw Setup?

    Skip the technical hassle. Our expert team handles installation, configuration, and ongoing support so you can focus on what matters.

    Related Articles