PJSIP Endpoint "Invalid URI" Error - Trunk Config Not Loading

Hello everyone,

I’m facing a persistent issue with my FreePBX installation and I’m hoping someone can help. I’m trying to configure an outbound PJSIP trunk to Twilio.

The Situation:

  • My WebRTC client (SIP.js) connects perfectly to Asterisk via WSS on port 57003.
  • My extension 101 authenticates successfully (I can see “Result: SUCCESS” in the logs).
  • The call from my extension correctly enters my custom dialplan context.

The Problem:
When the dialplan executes the Dial() command, it fails every time with the same error, which I can see in the Asterisk CLI (asterisk -rvvv):


Connected to Asterisk 18.20.2 currently running on freepbx (pid = 29455)
== WebSocket connection from ‘82.85.110.51:62633’ for protocol ‘sip’ accepted using version ‘13’
== Using SIP RTP Audio TOS bits 184
== Using SIP RTP Audio TOS bits 184 in TCLASS field.
== Using SIP RTP Audio CoS mark 5
== DTLS ECDH initialized (automatic), faster PFS enabled
[2025-06-19 12:12:57] ERROR[3070]: res_pjsip.c:993 ast_sip_create_dialog_uac: Endpoint ‘Trunk_CRM_Italia’: Could not create dialog to invalid URI ‘Trunk_CRM_Italia’. Is endpoint registered and reachable?
[2025-06-19 12:12:57] ERROR[3070]: chan_pjsip.c:2698 request: Failed to create outgoing session to endpoint ‘Trunk_CRM_Italia’
[2025-06-19 12:12:57] NOTICE[9872][C-0000000a]: app_dial.c:2719 dial_exec_full: Unable to create channel of type ‘PJSIP’ (cause 3 - No route to destination)
== Everyone is busy/congested at this time (1:0/0/1)
== Spawn extension (from-webrtc, 3317482208, 3) exited non-zero on ‘PJSIP/101-00000009’
[2025-06-19 12:22:58] ERROR[9468]: res_http_websocket.c:567 ws_safe_read: Error reading from web socket: No route to host
[2025-06-19 12:22:58] ERROR[29491]: iostream.c:552 ast_iostream_close: SSL_shutdown() failed: error:00000005:lib(0):func(0):DH lib, Underlying BIO error: Bad file descriptor
== WebSocket connection from ‘82.85.110.51:59160’ forcefully closed due to fatal write error
freepbx*CLI>
– Executing [3317482208@from-webrtc:1] NoOp(“PJSIP/101-…”)
– Executing [3317482208@from-webrtc:2] Dial(“PJSIP/101-…”, “PJSIP/3317482208@Trunk_CRM_Italia,60”)
ERROR[…]: res_pjsip.c: Endpoint ‘Trunk_CRM_Italia’: Could not create dialog to invalid URI ‘Trunk_CRM_Italia’. Is endpoint registered and reachable?
NOTICE[…]: app_dial.c: Unable to create channel of type ‘PJSIP’ (cause 3 - No route to destination)

What We’ve Tried (and didn’t work):

  • Creating the Trunk (Trunk_CRM_Italia) via the FreePBX GUI and carefully setting all parameters in the General and Advanced tabs (including SIP Server, Server URI, and From Domain). The setting seems to be ignored after an “Apply Config”.
  • Manually creating the trunk configuration in all possible custom files (pjsip_custom.conf, pjsip.endpoint_custom.conf, etc.). The configuration seems to be ignored by Asterisk.
  • Forcing the WSS transport settings directly into the FreePBX database via fwconsole mysql. This did not solve the trunk issue.
  • Reinstalling core modules (core, sipsettings) using fwconsole. This fixed a fwconsole reload hang, but the trunk problem persists.

It seems like my FreePBX installation is not correctly generating or loading the PJSIP configuration for this specific trunk endpoint, even though the Asterisk service is running fine.

Does anyone have any idea what could cause FreePBX to ignore the Server URI / AOR for a specific PJSIP endpoint? Is there a known bug or another file I should be checking?

My versions are:

  • FreePBX: 16.0.40.13
  • Asterisk: 18.20.2

Thank you for any help!

You are trying to do three complex things at once (WebRTC, new trunk, custom dialplan). Do one at a time and find the simplest thing that fails.

  1. Create a plain pjsip extension (with context from-internal) and register a softphone, IP phone or mobile SIP app to it. Confirm that you can call *65 and *43.
  2. Set the Context for your WebRTC extension to from-internal. Confirm that you can call between the extensions in both directions.
  3. Delete the Twilio trunk, configure it (entirely in the GUI), Submit and Apply Config. Report any errors shown on these steps. If the GUI does not show the new config, confirm that you have the latest version of Core. Twilio can use either IP auth or registration. As you mentioned the Server URI parameter (which is rarely needed and applies only to registration), I assume that you chose registration. Is your trunk registered? If not, find out why.
  4. With a suitable Outbound Route in place, confirm that you can make external calls from the pjsip extension.
  5. Once that’s working, try from the WebRTC extension.
  6. Once that’s working, enable your custom dialplan and test that.

If you want help at a particular step, turn on pjsip logger, make a failing test call to 18004377950, paste the Asterisk log (not the console log) for the call at pastebin.com and post the link here.

SSH into the system and show the output of

asterisk -rx "pjsip show endpoint Trunk_CRM_Italia"