407 4xx Client error RFC 3261
SIP 407 Proxy Authentication Required
Like 401, but the client must authenticate with the proxy. Carriers commonly challenge outbound INVITEs this way.
407 Proxy Authentication Required is a proxy's digest challenge. Carriers and hosted platforms commonly answer the first INVITE on an authenticated trunk with 407 and a Proxy-Authenticate header. Your PBX acknowledges it with ACK, then sends the INVITE again with a Proxy-Authorization header, the same Call-ID and a higher CSeq. A working trunk shows this pattern on every outbound call, and the caller never notices.
Unlike 401, which comes from a registrar or end device, 407 comes from an intermediary that wants to know who is using it. Your own proxy can send it too, to make sure your users' INVITEs are authenticated before calls leave your network.
It becomes a fault when the call stops at the 407 or the 407s repeat. Stopping means the PBX did not try to authenticate, usually because no outbound credentials are set for the trunk. Repeating means it tried and the username, password or realm was wrong. Either way the caller hears the call fail without ringing.
What it looks like in a SIP trace
PBX -> Carrier : INVITE sip:+27215550123@sip.example.net SIP/2.0 (CSeq 101)
Carrier -> PBX : SIP/2.0 407 Proxy Authentication Required
Proxy-Authenticate: Digest realm="sip.example.net", nonce="b7e1c0a95d34f2", algorithm=MD5, qop="auth"
PBX -> Carrier : ACK sip:+27215550123@sip.example.net SIP/2.0 (CSeq 101)
PBX -> Carrier : INVITE sip:+27215550123@sip.example.net SIP/2.0 (CSeq 102)
Proxy-Authorization: Digest username="trunk10045", realm="sip.example.net",
nonce="b7e1c0a95d34f2", uri="sip:+27215550123@sip.example.net",
response="9a0c4f1e7d2b6385e1f0c4a7b9d3e216", algorithm=MD5, qop=auth,
nc=00000001, cnonce="7f3a"
Carrier -> PBX : SIP/2.0 100 Trying
Carrier -> PBX : SIP/2.0 183 Session Progress
Example values only. Your headers, addresses and numbers will differ.
Common causes
- Normal digest challenge on outbound calls.
- Missing or wrong trunk credentials (looping 407s).
How to diagnose it
- Check that the PBX sends ACK and a second INVITE after the 407. If the call ends there, the trunk has no outbound authentication configured, or the configured realm does not match the challenge.
- If another 407 follows the authenticated INVITE, the digest was rejected. Check the username and password in the provider's portal, noting whether the username is an account number, a DID or something else.
- Make sure the nonce in
Proxy-Authorizationcomes from the latest challenge. A PBX that reuses an old nonce or answers with a different realm will loop. - Watch for 407 followed by 403. Authentication worked but the provider refused the call, so look at caller ID, destination permissions or account status instead.
- Compare the From user with the account. Some providers only accept the credentials when the From user or domain also matches the trunk, so a PBX that sends the extension number in From can fail with the right password.
How to fix it
- One 407 followed by a re-sent INVITE with Proxy-Authorization is normal.
- If calls fail at 407, set the trunk username and secret, and confirm the PBX is set to respond to challenges (for example, outbound auth in PJSIP).
Platform notes
Asterisk / FreePBX
In PJSIP the registration has its own outbound_auth, and the endpoint needs outbound_auth too, or outbound INVITEs stop at 407 while the trunk shows Registered. In FreePBX, set the trunk's Authentication option to Outbound (or Both) and check From User and From Domain on the Advanced tab. Leaving the auth realm blank usually lets Asterisk answer whatever realm the carrier sends.
OpenSIPS / Kamailio
When your proxy sits in front of a PBX, the carrier's 407 normally passes back to the PBX, which authenticates. If the proxy must authenticate itself, call uac_auth() in a failure route with the trunk credentials set as module parameters; in OpenSIPS the retry is a new branch, so re-apply any forced outbound socket before relaying it.
SIP 407 FAQ
Is 407 Proxy Authentication Required an error?
Not on its own. One 407 per call is normal on authenticated trunks. It is a problem only if the call stops there or the challenge keeps repeating.
Why does my trunk register but outbound calls fail with 407?
REGISTER and INVITE authentication are often configured separately on the PBX. The registration can succeed while the INVITE has no credentials attached, so check both.
Why do I get 404 from my carrier without ever seeing a 407?
On a trunk that normally challenges you, a missing 407 suggests the carrier did not recognise the call as coming from your account, often because of the From domain or user. Fix your identity headers before investigating the number.
Related codes
Related guides
SIP Registration Failed? Troubleshooting Checklist
Fix failed SIP registrations step by step: read 401, 403, 404, 408, 423 and 503 replies, then check DNS, ports, NAT, fail2ban bans and Asterisk PJSIP.
Capture SIP Traces With sngrep and Wireshark
Capture SIP and RTP with sngrep and tcpdump, then analyse calls in Wireshark: call flows, RTP stream analysis, jitter, loss, audio playback and safe sharing.