Fixing PJSIP MWI SUBSCRIBE 500 Errors in Asterisk

Troubleshooting -- Last reviewed 2026-04-01 pjsip voicemail mwi Found this useful? Upvote it. ×

The Problem

Asterisk responds with 500 Server Internal Error to every MWI SUBSCRIBE request from phones, flooding logs with errors like:

res_pjsip_mwi.c: Failed to add topic ... to MWI aggregate subscription

Phones show no voicemail indicator (MWI lamp stays off) even when messages are waiting.

Root Cause

When both the PJSIP endpoint and its AOR have mailboxes set to the same value, and the default setting mwi_subscribe_replaces_unsolicited = no is in effect, Asterisk enters a conflict:

  1. The AOR's mailboxes setting triggers unsolicited MWI NOTIFY (push)
  2. The endpoint's mailboxes setting enables solicited MWI via SUBSCRIBE
  3. When the phone sends a SUBSCRIBE, Asterisk tries to set up a solicited subscription but the mailbox is already claimed by the unsolicited handler
  4. Result: 500 error on every SUBSCRIBE

How to Confirm

Check MWI subscription status:

asterisk -rx 'pjsip show subscriptions inbound' | grep message-summary

If you see far fewer active subscriptions than expected (e.g., 1 out of 12), this is the issue.

To confirm definitively, look for the pattern: any endpoint where the AOR mailboxes value accidentally differs from the endpoint mailboxes value will be the one that works. The mismatch avoids the conflict.

The Fix

Add mwi_subscribe_replaces_unsolicited = yes to your endpoint template:

[endpoint-internal](!)
type = endpoint
context = internal
disallow = all
allow = ulaw,alaw,g722
direct_media = no
trust_id_outbound = yes
trust_id_inbound = yes
dtmf_mode = rfc4733
rewrite_contact = yes
rtp_symmetric = yes
force_rport = yes
rtp_keepalive = 15
device_state_busy_at = 1
media_encryption = sdes
mwi_subscribe_replaces_unsolicited = yes   ; <-- THE FIX

This tells Asterisk: when a phone sends a SUBSCRIBE for a mailbox that already has an unsolicited handler, replace the unsolicited with the solicited subscription instead of erroring out.

Also Check for AOR Mailbox Typos

While debugging, check that each AOR's mailboxes value actually matches the correct mailbox. Copy-paste errors are common when setting up multiple endpoints:

; WRONG - copy-paste bug, should be 8151@default
[8151-mit](aor-internal)
mailboxes = 8150@default

; CORRECT
[8151-mit](aor-internal)
mailboxes = 8151@default

Applying the Fix

# Edit pjsip.conf and add the setting to your template
# Then reload:
asterisk -rx 'module reload res_pjsip'

# Verify - should show all expected subscriptions
asterisk -rx 'pjsip show subscriptions inbound' | grep message-summary

Why Both endpoint AND AOR Need mailboxes

You might ask: why set mailboxes on both?

Both are needed. The mwi_subscribe_replaces_unsolicited setting resolves the conflict between them.

Expected Result

Before fix:

$ asterisk -rx 'pjsip show subscriptions inbound' | grep -c message-summary
1

After fix:

$ asterisk -rx 'pjsip show subscriptions inbound' | grep -c message-summary
12

User Notes

No notes yet. Be the first to contribute a tip or example.

Contribute a note

Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.

Moderated before publishing. Email never shown.

Related Snippets