Setting Freepbx 17 with Twilio

Hi everyone,

I’m new to FreePBX and VoIP PBX systems, and I’m currently trying to set up a FreePBX 17 server running on an AWS EC2 instance (Debian 12).

I used the official Sangoma installation script, and the setup went smoothly. I’m using a PSTN number from Twilio, and I’m now in the process of configuring trunks to make and receive calls.

However, when I try to place a call, it seems Twilio is not reaching my PBX server. I don’t hear any ringing, and in the Twilio logs, I consistently see:

Request timeout with sip:+1[MY_TWILIO_PHONE_NUMBER]@[MY_FREEPBX_IP_ADDRESS]:5060

Here’s a summary of my current setup:

AWS Security Group Settings

I’ve allowed traffic from the following IP ranges:

SIP Signaling:

  • 54.172.60.0/30 (UDP/TCP 5060) – US Region 1
  • 54.244.51.0/30 (UDP/TCP 5060) – US Region 2
  • 67.213.136.64/30 – Twilio Signaling IPs

Media (RTP):

  • 168.86.128.0/18 (UDP ports 10000–20000)

FreePBX Firewall Settings

I added the above IP ranges to the FreePBX firewall under the “Trusted” zone (excluded from filtering).


Trunk Configuration (PJSIP)

  • Username & Auth Username: Matches the Twilio Credential List
  • Secret: Matches the Twilio Credential List
  • Authentication: Outbound
  • Registration: None
  • SIP Server: [my_twilio_uri].pstn.ashburn.twilio.com
  • SIP Server Port: 5060
  • Context: from-pstn
  • Transport: 0.0.0.0-udp

Advanced Settings:

  • DTMF Mode: Auto
  • Outbound Proxy: sip:[my_twilio_uri].ashburn.twilio.com:5060
  • From Domain: [my_twilio_uri].pstn.ashburn.twilio.com
  • From User: Twilio Credential Username

Despite all of the above, calls still time out. I’m not sure what I might be missing — whether it’s a configuration step, a network rule, or something else.

Any help or pointers would be greatly appreciated!

Thanks in advance,
Carlos

Hello, I got same problems on very beginning.
When you did sip trunk setup on twilio side, how authorization works there?
Most better way use only IP and Termination - Credential Lists - should be empty.
That helped me - you can check my topic too - No matching endpoint found - Twilio and FreePBX

1 Like

For the trunk settings, you want just the username, not “auth username” filled, if you set up credentials on Twilios side. You want DTMF mode set to “RFC 4733”, and also in the trunk settings, you want the context set to “from-pstn-e164-us”. This context is built in to convert the number from E.164 format to a 10 digit number. Make sure you have ulaw checked for the codec, as that’s what Twilio uses by default. Clear the “From Domain”, “From User”, and “From Proxy” fields in the advanced tab, they are not necessary. Then in your inbound route for any DIDs, enter just the 10 digit number “3214567000” DID. Everything else you have set is correct.

Hi Guys, thanks for the suggestions, I’m close to getting it to work, but now I’m having an issue with the firewall in that I’m being locked out from the Web UI and SSH, not sure why. My server is running in AWS. If I reboot the server from aws console, I can access the web ui for a couple of minutes and then I loose connectivity again. (my guess is that while the firewall is starting I can access the ui but once it starts I’m locked out).. As to SSH I can’t login not even right after reboot. I tried disabling the firewall in the web ui but I’m still being locked out. Any ideas what might be happening?

Thanks

Carlos