Received response: “Forbidden” from ‘<sip:12345@:5060>;tag=as057df08d’

Dear team,

iam facing issue in making outgoing call. please help to fix it

message in asterisk:

CLI> !python /root/

– Attempting call on SIP/mainsip/+ for @test:1 (Retry 1)
== Using SIP RTP CoS mark 5
– Called mainsip/+
[Mar 14 06:37:51] WARNING[33245]: chan_sip.c:24424 handle_response_invite: Received response: “Forbidden” from ‘<sip:12345@:5060>;tag=as057df08d’
[Mar 14 06:37:51] NOTICE[35260]: pbx_spool.c:450 attempt_thread: Call failed to go through, reason (0) Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)
[Mar 14 06:37:51] NOTICE[35260]: pbx_spool.c:453 attempt_thread: Queued call to SIP/mainsip/+ expired without completion after 0 attempts

CLI> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
mainsip/mainsip Yes Yes 5060 OK (116 ms)

sip conf below


Python file content:

cat /root/
import psycopg2,os
from psycopg2 import Error

cursor = conn.cursor()
cursor.execute(“select mobno from numbers where flag=0”)
record = cursor.fetchall()

for records in record:
    mobno = str(records[0])

    os.system('rm -rf /var/spool/asterisk/Numbers/'+mobno)
    file = open('/var/spool/asterisk/Numbers/'+mobno, 'a')
    file.write('Channel: SIP/mainsip/+'+mobno)
    file.write('\nContext: test')
    file.write('\nExtension: +'+mobno)
    file.write('\nPriority: 1')
    file.write('\nCallerID: 12345')
    os.system('cp /var/spool/asterisk/Numbers/'+mobno+ ' /var/spool/asterisk/outgoing/')

except (Exception, Error) as error:
print “H”;
if (conn):

thanks and regards

The call was sent to the target. The target rejected it due to lack of authentication. You have “” port 5060 in “sip show peers”. What is this? Is this the same Asterisk? Are you having Asterisk call itself?

Also, you are using an obsolete channel driver, with a configuration that is clearly copied and pasted, as it contains common minor errors that are typical of configurations that were copied and pasted without checking against the documentation. Actually there is one big error as well, in that insecure=invite basically nullifies secret here, and I can’t think of a real life reason for real life reason for using it in combination with host=dynamic. If the registrant really does want Asterisk to authenticate itself, this would be sufficient to cause an authentication failure, however typical registrants don’t expect the UAS to authenticate itself, as that will fail with typical ITSPs.

From the nature of your question, I think you are new to Asterisk, in which case there is no valid reason to use chan_sip.

PS Please mark up logs and code as pre-formatted text

PPS there is no team; this is a peer support forum.

For a loop back, and think we would have had the other side of the failure logged. I suspect inconsistent redaction styles, by the OP.

Although I think you would still get the UAS side failure logged, if this is actually FreePBX, it could be a call from chan_sip (on a non-standard port) to chan_pjsip.

A very simple loop back would not try to authenticate, because of the insecure setting.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.