gamlin commited on
Commit
9c8f0f8
·
verified ·
0 Parent(s):

initial commit

Browse files
Files changed (2) hide show
  1. .gitattributes +35 -0
  2. README.md +555 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - vicidial
5
+ - call-center
6
+ - sip
7
+ - registration
8
+ - failed
9
+ ---
10
+
11
+ # SIP Registration Failed: Every Error Code Explained With Fixes
12
+
13
+ **Last updated: March 2026 | Reading time: ~22 minutes** You're looking at the Asterisk CLI and you see it. Over and over: ``` [2026-03-26 08:14:32] NOTICE[12847]: chan_sip.c:24022 handle_response_register: Registration for 'trunk_voipcarrier' failed ``` Or maybe you're not even using Asterisk. Maybe it's a Grandstream phone, a softphone, FreePBX, or some other SIP endpoint. The message is always some variation of the same thing: **SIP [registration failed](/blog/sip-registration-failed-fix/)**. This is the most common SIP error in existence. It has about 15 different causes. The [error message](/blog/vicidial-dnc-management/) itself tells you almost nothing. The actual answer is hiding in the SIP response code, and most admin interfaces don't show it to you. This guide covers every SIP registration failure mode I've encountered across thousands of VoIP deployments. Real packet captures, real Asterisk output, real fixes. --- Before troubleshooting, you need to know what's happening behind the scenes. SIP registration is a four-step process: ```...
14
+
15
+ ## Overview
16
+
17
+ **Last updated: March 2026 | Reading time: ~22 minutes**
18
+
19
+ You're looking at the Asterisk CLI and you see it. Over and over:
20
+
21
+ ```
22
+ [2026-03-26 08:14:32] NOTICE[12847]: chan_sip.c:24022 handle_response_register: Registration for 'trunk_voipcarrier' failed
23
+ ```
24
+
25
+ Or maybe you're not even using Asterisk. Maybe it's a Grandstream phone, a softphone, FreePBX, or some other SIP endpoint. The message is always some variation of the same thing: **SIP [registration failed](/blog/sip-registration-failed-fix/)**.
26
+
27
+ This is the most common SIP error in existence. It has about 15 different causes. The [error message](/blog/vicidial-dnc-management/) itself tells you almost nothing. The actual answer is hiding in the SIP response code, and most admin interfaces don't show it to you.
28
+
29
+ This guide covers every SIP registration failure mode I've encountered across thousands of VoIP deployments. Real packet captures, real Asterisk output, real fixes.
30
+
31
+ ---
32
+
33
+ ## How SIP Registration Works (30-Second Version)
34
+
35
+ Before troubleshooting, you need to know what's happening behind the scenes. SIP registration is a four-step process:
36
+
37
+ ```
38
+ Endpoint Registrar (carrier/PBX)
39
+ │ │
40
+ │──── REGISTER (no auth) ──────────→│
41
+ │ │
42
+ │←─── 401 Unauthorized ─────────────│
43
+ │ (includes nonce/challenge) │
44
+ │ │
45
+ │──── REGISTER (with digest auth) ─→│
46
+ │ (username + MD5 response) │
47
+ │ │
48
+ │←─── 200 OK ───────────────────────│
49
+ │ (registered, expires: 3600) │
50
+ ```
51
+
52
+ Step 1: Your phone/PBX sends a REGISTER request without credentials.
53
+ Step 2: The registrar replies with 401 Unauthorized, including a challenge (nonce).
54
+ Step 3: Your device computes an MD5 digest from the nonce + your password and sends a second REGISTER.
55
+ Step 4: Registrar verifies the digest and replies 200 OK. You're registered.
56
+
57
+ If anything goes wrong in steps 1-4, registration fails. The response code tells you WHERE it failed. Let's go through every one.
58
+
59
+ ---
60
+
61
+ ## Capturing the SIP Response Code
62
+
63
+ You can't fix what you can't see. Most SIP devices just show "registration failed" without the response code. Here's how to get it.
64
+
65
+ ### On Asterisk/VICIdial
66
+
67
+ ```bash
68
+ # Live SIP debugging — shows every SIP message
69
+ asterisk -rx "sip set debug on"
70
+
71
+ # Check current registration status of all peers
72
+ asterisk -rx "sip show peers"
73
+
74
+ # Check a specific peer's registration
75
+ asterisk -rx "sip show peer trunk_name"
76
+
77
+ # For PJSIP (Asterisk 16+, ViciBox 12+)
78
+ asterisk -rx "pjsip set logger on"
79
+ asterisk -rx "pjsip show registrations"
80
+ ```
81
+
82
+ ### On the Network (Any Device)
83
+
84
+ ```bash
85
+ # sngrep — the best SIP debugging tool
86
+ sngrep -d eth0 port 5060
87
+
88
+ # tcpdump if sngrep isn't available
89
+ tcpdump -i eth0 -n -s 0 port 5060 -w /tmp/sip.pcap
90
+ # Then open in Wireshark on your local machine
91
+ ```
92
+
93
+ sngrep is invaluable. It shows SIP message flows in real time with a curses UI. If you don't have it installed:
94
+
95
+ ```bash
96
+ # AlmaLinux / Rocky / CentOS Stream
97
+ dnf install sngrep
98
+
99
+ # Debian / Ubuntu
100
+ apt install sngrep
101
+
102
+ # OpenSuSE (ViciBox)
103
+ zypper install sngrep
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Every SIP Registration Error Code
109
+
110
+ ### 400 Bad Request
111
+
112
+ **What the registrar is saying:** "Your REGISTER message is malformed. I can't parse it."
113
+
114
+ **Common causes:**
115
+ - Malformed SIP URI in the From or To header
116
+ - Invalid characters in the username or domain
117
+ - Broken SIP stack on the endpoint (rare, but happens with cheap hardware)
118
+ - SIP ALG on a NAT router rewriting headers incorrectly
119
+
120
+ **The fix:**
121
+
122
+ First, disable SIP ALG on your router/firewall. SIP ALG is supposed to help SIP through NAT. In reality, it corrupts SIP messages about 80% of the time. If you are dealing with NAT issues [for remote agents](/blog/vicidial-34-new-features/) specifically, see our [remote agent setup guide](/blog/vicidial-remote-agent-setup/) for complete NAT traversal configuration and our [WebRTC setup guide](/blog/vicidial-webrtc-setup/) for an approach that avoids SIP NAT issues entirely.
123
+
124
+ ```bash
125
+ # Check if SIP ALG is active (Linux iptables)
126
+ lsmod | grep nf_nat_sip
127
+
128
+ # Disable it
129
+ modprobe -r nf_nat_sip nf_conntrack_sip
130
+ echo "blacklist nf_nat_sip" >> /etc/modprobe.d/blacklist.conf
131
+ echo "blacklist nf_conntrack_sip" >> /etc/modprobe.d/blacklist.conf
132
+ ```
133
+
134
+ If it's not SIP ALG, check the From and To headers in your SIP trace. The domain portion needs to match what the registrar expects. On Asterisk:
135
+
136
+ ```ini
137
+ ; sip.conf — make sure fromdomain matches the carrier's expected domain
138
+ [trunk_carrier]
139
+ type=peer
140
+ host=sip.carrier.com
141
+ fromdomain=sip.carrier.com ; This matters
142
+ fromuser=your_account_id
143
+ ```
144
+
145
+ ### 401 Unauthorized (After Second REGISTER)
146
+
147
+ **What the registrar is saying:** "You sent credentials, but they're wrong."
148
+
149
+ This is the classic authentication failure. The first 401 is normal (it's the challenge). A 401 after you've responded to the challenge means your credentials don't match.
150
+
151
+ **Common causes:**
152
+ - Wrong password (the #1 cause, by far)
153
+ - Wrong username (SIP auth username ≠ SIP URI username on many carriers)
154
+ - Wrong realm/domain in the digest calculation
155
+ - Password has special characters that aren't being escaped correctly
156
+ - Carrier changed credentials and didn't tell you (or it went to the spam folder)
157
+
158
+ **The fix:**
159
+
160
+ In Asterisk, verify your trunk credentials:
161
+
162
+ ```bash
163
+ # Check what Asterisk thinks the credentials are
164
+ asterisk -rx "sip show peer trunk_name" | grep -i "secret\|username\|auth"
165
+ ```
166
+
167
+ Cross-reference with your carrier portal. Pay attention to:
168
+ - **Auth username** vs **SIP username** — many carriers have two different usernames. The auth username goes in the REGISTER challenge response. The SIP username goes in the From header.
169
+ - **Realm** — some carriers require a specific realm in the digest. Check the 401 response to see what realm they're challenging with.
170
+
171
+ In the VICIdial admin GUI, go to **Carriers** and verify the trunk configuration. The username and password fields need to match exactly what your carrier issued.
172
+
173
+ ```ini
174
+ ; sip.conf
175
+ [trunk_carrier]
176
+ type=peer
177
+ host=sip.carrier.com
178
+ username=auth_username ; Often different from the account ID
179
+ secret=yourpassword123
180
+ fromuser=sip_username ; The From header username
181
+ ```
182
+
183
+ ### 403 Forbidden
184
+
185
+ **What the registrar is saying:** "I know who you are, but you're not allowed to register."
186
+
187
+ **Common causes:**
188
+ - IP address not whitelisted (carrier requires IP auth + registration)
189
+ - Account suspended or disabled
190
+ - Registration from a blocked region/country
191
+ - Exceeded maximum registration count (too many devices on one account)
192
+ - Anti-fraud system triggered (registrations from multiple IPs simultaneously)
193
+
194
+ **The fix:**
195
+
196
+ Log into your carrier's portal and check:
197
+ 1. Account status — is it active?
198
+ 2. IP whitelist — does it include your server's public IP?
199
+ 3. Concurrent registration limit — have you exceeded it?
200
+
201
+ If your server is behind NAT, the carrier sees your public IP, not your private one. Make sure the public IP is whitelisted.
202
+
203
+ ```bash
204
+ # Find your server's public IP
205
+ curl -s ifconfig.me
206
+ ```
207
+
208
+ For VICIdial systems where the Asterisk server is behind a firewall, verify `externip` in sip.conf:
209
+
210
+ ```ini
211
+ ; sip.conf
212
+ externip=YOUR.PUBLIC.IP.ADDRESS
213
+ localnet=192.168.1.0/255.255.255.0
214
+ localnet=10.0.0.0/255.0.0.0
215
+ ```
216
+
217
+ ### 404 Not Found
218
+
219
+ **What the registrar is saying:** "The SIP address you're trying to register doesn't exist on my system."
220
+
221
+ **Common causes:**
222
+ - Wrong registrar domain/hostname
223
+ - Wrong SIP username (the user portion of the SIP URI)
224
+ - Account deleted on the carrier side
225
+ - Typo in the `register =>` line
226
+
227
+ **The fix:**
228
+
229
+ Check your registration string. In Asterisk chan_sip:
230
+
231
+ ```ini
232
+ ; sip.conf
233
+ register => username:password@sip.carrier.com/inbound_context
234
+ ```
235
+
236
+ The hostname after `@` needs to resolve to the carrier's registrar. The username needs to be a valid account on that registrar. A 404 means one of these is wrong.
237
+
238
+ ```bash
239
+ # Verify DNS resolution
240
+ dig sip.carrier.com
241
+
242
+ # Some carriers use SRV records
243
+ dig _sip._udp.carrier.com SRV
244
+ ```
245
+
246
+ ### 407 Proxy Authentication Required
247
+
248
+ **What the registrar is saying:** "You need to authenticate with my proxy, not just the registrar."
249
+
250
+ This is similar to 401 but for proxy authentication. Some SIP networks route REGISTER through a proxy that requires its own authentication step.
251
+
252
+ **Common causes:**
253
+ - Same as 401 (wrong credentials) but for the proxy auth layer
254
+ - Missing `outboundproxy` configuration
255
+ - Carrier uses an SBC (Session Border Controller) that requires proxy auth
256
+
257
+ **The fix:**
258
+
259
+ Add proxy auth credentials in Asterisk:
260
+
261
+ ```ini
262
+ ; sip.conf
263
+ [trunk_carrier]
264
+ type=peer
265
+ host=sip.carrier.com
266
+ outboundproxy=proxy.carrier.com
267
+ username=your_username
268
+ secret=your_password
269
+ ```
270
+
271
+ ### 408 Request Timeout
272
+
273
+ **What the registrar is saying:** Nothing. That's the problem. The registrar didn't respond at all, and your device gave up waiting.
274
+
275
+ **Common causes:**
276
+ - Firewall blocking UDP port 5060 outbound
277
+ - Carrier's registrar is down
278
+ - DNS not resolving (REGISTER sent to wrong IP or not sent at all)
279
+ - Network path issue (routing, ISP problem)
280
+ - SIP ALG or NAT breaking the return path so the response can't get back
281
+ - Wrong transport (sending UDP when carrier expects TCP, or vice versa)
282
+
283
+ This is the most frustrating error because it means your REGISTER went into a black hole. It could be a firewall issue, a DNS issue, or a network issue. The registrar may have never seen your request.
284
+
285
+ **The fix:**
286
+
287
+ Work from the bottom up:
288
+
289
+ ```bash
290
+ # 1. Can you reach the registrar at all?
291
+ ping sip.carrier.com
292
+
293
+ # 2. Can you reach port 5060?
294
+ nc -zuv sip.carrier.com 5060
295
+
296
+ # 3. Does DNS resolve correctly?
297
+ dig sip.carrier.com
298
+
299
+ # 4. Is your firewall allowing outbound UDP 5060?
300
+ iptables -L -n | grep 5060
301
+
302
+ # 5. Can you see any SIP traffic at all?
303
+ tcpdump -i eth0 -n port 5060 -c 10
304
+ ```
305
+
306
+ If tcpdump shows REGISTER going out but no response coming back, the problem is either the carrier's firewall (they need to whitelist your IP) or a NAT/ALG issue mangling the return path.
307
+
308
+ Check your transport. Some carriers require TCP instead of UDP:
309
+
310
+ ```ini
311
+ ; sip.conf
312
+ [trunk_carrier]
313
+ type=peer
314
+ host=sip.carrier.com
315
+ transport=tcp ; Try this if UDP isn't working
316
+ ```
317
+
318
+ ### 423 Interval Too Brief
319
+
320
+ **What the registrar is saying:** "You're trying to register with an expiry time that's too short. I require a longer registration interval."
321
+
322
+ **Common causes:**
323
+ - Your device is set to register every 30 or 60 seconds
324
+ - The carrier requires a minimum registration interval (usually 120 or 300 seconds)
325
+
326
+ **The fix:**
327
+
328
+ Increase the registration expiry:
329
+
330
+ ```ini
331
+ ; sip.conf
332
+ [trunk_carrier]
333
+ type=peer
334
+ defaultexpiry=300 ; 5 minutes
335
+ ```
336
+
337
+ Or in PJSIP:
338
+
339
+ ```ini
340
+ ; pjsip.conf
341
+ [trunk_carrier]
342
+ type=registration
343
+ expiration=300
344
+ ```
345
+
346
+ ### 480 Temporarily Unavailable
347
+
348
+ **What the registrar is saying:** "I exist and I heard you, but I can't handle your registration right now."
349
+
350
+ **Common causes:**
351
+ - Carrier is overloaded
352
+ - Maintenance window
353
+ - Rate limiting (you're sending too many REGISTER requests)
354
+
355
+ **The fix:**
356
+
357
+ Wait and retry. If it persists, contact your carrier. If you're sending rapid-fire registration attempts (because your system keeps retrying after each failure), you might be getting rate-limited. Increase your retry interval:
358
+
359
+ ```ini
360
+ ; sip.conf
361
+ registertimeout=60 ; Wait 60 seconds between retry attempts
362
+ registerattempts=0 ; Keep retrying forever (0 = infinite)
363
+ ```
364
+
365
+ ### 500 Internal Server Error
366
+
367
+ **What the registrar is saying:** "Something broke on my end."
368
+
369
+ **Common causes:**
370
+ - Bug in the carrier's SBC or registrar software
371
+ - Database issue on the carrier side
372
+ - Malformed data in your REGISTER that triggers a server bug
373
+
374
+ **The fix:**
375
+
376
+ This is the carrier's problem. Contact their support with your SIP trace showing the 500 response. Include the Call-ID header so they can track it in their logs.
377
+
378
+ If you're getting 500s intermittently, it might be a load issue on their side. Configure a failover trunk so your system can switch carriers when one is having problems.
379
+
380
+ ### 503 Service Unavailable
381
+
382
+ **What the registrar is saying:** "I'm alive but not accepting registrations. Maybe I'm in maintenance, overloaded, or you're hitting a rate limit."
383
+
384
+ **Common causes:**
385
+ - Carrier at capacity
386
+ - Server maintenance
387
+ - Your account has been soft-disabled (carrier is rejecting your registrations but the account technically exists)
388
+ - Load balancer has no healthy backends
389
+
390
+ **The fix:**
391
+
392
+ Same as 500 — carrier-side issue. The difference is 503 is more likely temporary. Check your carrier's status page. Set up failover trunks.
393
+
394
+ In VICIdial, configure a secondary carrier through the admin GUI under **Carriers**. Set up dial patterns that try the primary trunk first and fall back to the secondary.
395
+
396
+ ---
397
+
398
+ ## SIP Registration Over TLS (SIPS)
399
+
400
+ If your carrier supports SIP over TLS (port 5061), use it. It encrypts the signaling path, prevents credential sniffing, and eliminates a class of NAT/ALG issues because TLS traffic is less likely to be mangled by middleboxes.
401
+
402
+ ```ini
403
+ ; sip.conf
404
+ [trunk_carrier]
405
+ type=peer
406
+ host=sip.carrier.com
407
+ transport=tls
408
+ port=5061
409
+ tlscafile=/etc/pki/tls/certs/ca-bundle.crt
410
+ tlsenable=yes
411
+ tlsverify=yes
412
+ ```
413
+
414
+ For PJSIP (Asterisk 16+ / ViciBox 12.0.2):
415
+
416
+ ```ini
417
+ ; pjsip.conf
418
+ [transport-tls]
419
+ type=transport
420
+ protocol=tls
421
+ bind=0.0.0.0:5061
422
+ cert_file=/etc/asterisk/keys/asterisk.crt
423
+ priv_key_file=/etc/asterisk/keys/asterisk.key
424
+ ca_list_file=/etc/pki/tls/certs/ca-bundle.crt
425
+ method=tlsv1_2
426
+
427
+ [trunk_carrier]
428
+ type=registration
429
+ transport=transport-tls
430
+ outbound_auth=trunk_carrier_auth
431
+ server_uri=sips:sip.carrier.com
432
+ client_uri=sips:your_number@sip.carrier.com
433
+ ```
434
+
435
+ Common TLS registration failures:
436
+ - **Certificate verification failure** — The carrier's cert is self-signed or your CA bundle is outdated. Either add their cert to your trust store or set `tlsverify=no` (less secure but functional).
437
+ - **Wrong TLS version** — Some carriers still require TLS 1.2. Others have upgraded to 1.3. Check with your carrier.
438
+ - **Port 5061 blocked** — Your firewall allows 5060 (UDP) but blocks 5061 (TCP/TLS).
439
+
440
+ ---
441
+
442
+ ## SIP Registration Behind NAT: The Eternal Problem
443
+
444
+ 90% of SIP registration failures in the real world are NAT-related. Here's why.
445
+
446
+ When your Asterisk server sends a REGISTER from behind NAT, the SIP message contains the private IP (e.g., 192.168.1.100) in the Contact header. The carrier sends the 200 OK response to your public IP (which your router forwards correctly). But when the carrier later tries to send an INVITE to your registered contact address, it tries to reach 192.168.1.100 — which is unreachable from the internet.
447
+
448
+ The fix involves multiple layers:
449
+
450
+ ```ini
451
+ ; sip.conf
452
+ nat=force_rport,comedia ; Force rport and symmetric RTP
453
+ externip=YOUR.PUBLIC.IP ; Tell Asterisk what your public IP is
454
+ localnet=192.168.1.0/255.255.255.0 ; Define your private network
455
+ qualify=yes ; Send OPTIONS keepalives to maintain NAT mapping
456
+ qualifyfreq=30 ; Every 30 seconds
457
+ ```
458
+
459
+ The `qualify=yes` with `qualifyfreq=30` sends SIP OPTIONS messages every 30 seconds, which keeps the NAT mapping alive on your router. Without this, the NAT mapping expires (typically after 30-60 seconds), and inbound SIP messages can't reach your server.
460
+
461
+ For firewalls that do connection tracking, you also need to keep the UDP "connection" alive. The qualify setting handles this for SIP, but you also need to consider RTP (media) ports:
462
+
463
+ ```bash
464
+ # Open RTP port range in firewall
465
+ iptables -A INPUT -p udp --dport 10000:20000 -j ACCEPT
466
+ ```
467
+
468
+ ---
469
+
470
+ ## PJSIP vs. chan_sip Registration Differences
471
+
472
+ If you're on Asterisk 18+ (ViciBox 12.0.2), you have both chan_sip and PJSIP available. VICIdial traditionally uses chan_sip, but PJSIP is the future and handles some registration scenarios better.
473
+
474
+ Key differences for registration:
475
+
476
+ | Feature | chan_sip | PJSIP |
477
+ |---------|---------|-------|
478
+ | Config file | sip.conf | pjsip.conf |
479
+ | Registration syntax | `register =>` line | Separate `registration` object |
480
+ | Multiple registrations to same host | Awkward | Clean, separate objects |
481
+ | TLS support | Basic | Full, modern |
482
+ | DNS SRV | Limited | Full support |
483
+ | Outbound proxy | Basic | Full support |
484
+
485
+ If you're getting registration failures with chan_sip that you can't resolve, try the same trunk in PJSIP. We've seen cases where chan_sip's digest authentication implementation doesn't handle certain carrier challenge formats correctly, while PJSIP handles them fine.
486
+
487
+ ---
488
+
489
+ ## Automated Registration Monitoring
490
+
491
+ Don't wait for agents to tell you the phones aren't working. Monitor registration status automatically.
492
+
493
+ ```bash
494
+ #!/bin/bash
495
+ # sip-reg-check.sh — Run from cron every 5 minutes
496
+ PEERS=$(asterisk -rx "sip show peers" | grep -c "UNREACHABLE\|UNKNOWN")
497
+ if [ "$PEERS" -gt 0 ]; then
498
+ echo "WARNING: $PEERS SIP peers unreachable" | mail -s "SIP Registration Alert" admin@yourcompany.com
499
+ # Log for trending
500
+ echo "$(date): $PEERS peers down" >> /var/log/sip-registration-monitor.log
501
+ fi
502
+ ```
503
+
504
+ For VICIdial specifically, you can also monitor from the Real-Time Report. If trunks show as unregistered, the **Server Stats** page in the admin will show carrier status.
505
+
506
+ ---
507
+
508
+ ## Quick Reference: Registration Failure Cheat Sheet
509
+
510
+ | Code | Meaning | First Thing to Check |
511
+ |------|---------|---------------------|
512
+ | 400 | Bad Request | Disable SIP ALG, check SIP URI format |
513
+ | 401 | Auth Failed | Password, auth username vs SIP username |
514
+ | 403 | Forbidden | IP whitelist, account status |
515
+ | 404 | Not Found | Username, registrar hostname |
516
+ | 407 | Proxy Auth | Outbound proxy credentials |
517
+ | 408 | Timeout | Firewall, DNS, network path |
518
+ | 423 | Interval Too Short | Increase registration expiry |
519
+ | 480 | Temporarily Unavailable | Carrier issue, retry later |
520
+ | 500 | Server Error | Carrier-side bug, contact support |
521
+ | 503 | Service Unavailable | Carrier overloaded, use failover |
522
+
523
+ ---
524
+
525
+ ## When to Stop Debugging and Call the Carrier
526
+
527
+ If you've verified:
528
+ - Credentials match the carrier portal exactly
529
+ - DNS resolves correctly
530
+ - Firewall allows SIP traffic bidirectionally
531
+ - SIP ALG is disabled
532
+ - NAT is configured properly
533
+ - sngrep shows your REGISTER going out and a non-401 error coming back
534
+
535
+ Then the problem is on the carrier side. Call them. Give them:
536
+ 1. Your account ID
537
+ 2. The source IP of your REGISTER attempts
538
+ 3. The exact response code you're getting
539
+ 4. A pcap file if possible
540
+
541
+ Good carriers will resolve this in minutes. Bad carriers will tell you to reboot your PBX.
542
+
543
+ ---
544
+
545
+ **Tired of debugging SIP registration at 2 AM?** ViciStack builds and manages VICIdial infrastructure on [bare metal](/blog/vicidial-setup-guide/) with pre-configured, tested SIP trunks and automatic failover. Registration monitoring is built into our standard deployment. Our engagement starts at $5K ($1K deposit, $4K on completion) and includes full SIP trunk configuration with your carriers. [Talk to us](/contact/) before the next outage.
546
+
547
+ ---
548
+
549
+ *Related: [VICIdial SIP Troubleshooting](/blog/vicidial-sip-troubleshooting/) | [VICIdial Asterisk Configuration](/blog/vicidial-asterisk-configuration/) | [VICIdial SIP Trunk Failover](/blog/vicidial-sip-trunk-failover/) | [Asterisk PJSIP TLS Guide](/blog/asterisk-pjsip-tls-openssl3-guide/)*
550
+
551
+ ## Resources
552
+
553
+ - [Read the full article](https://vicistack.com/blog/sip-registration-failed-fix/) on ViciStack
554
+ - [ViciStack](https://vicistack.com) - VICIdial hosting and optimization
555
+ - [Free VICIdial Audit](https://vicistack.com/free-audit/)