ASTERISK – netsock2.c:305 ast_sockaddr_resolve: getaddrinfo(“raspbx”, “(null)”, …): Temporary failure in name resolution

Sometime when you start running Asterisk you may get the below error, which causes delay in call connection etc.

      > 0x104be738 -- Strict RTP learning after remote address set to: 192.168.1.103:14446
    -- Executing [1002@PA:1] Dial("SIP/1001-00000000", "SIP/1002,20") in new stack
[Sep  2 10:32:37] WARNING[772][C-00000000]: app_dial.c:2527 dial_exec_full: Unable to create channel of type 'SIP' (cause 20 - Subscriber absent)
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Auto fallthrough, channel 'SIP/1001-00000000' status is 'CHANUNAVAIL'
    -- Executing [h@PA:1] Set("SIP/1001-00000000", "CDR(userfield)= Quality: R/W:alaw/alaw N:(alaw) Priority : 1") in new stack
    -- Registered SIP '1002' at 192.168.1.102:15998
       > Saved useragent "MizuDroid/3.1.0" for peer 1002
[Sep  2 10:32:49] NOTICE[747]: chan_sip.c:24646 handle_response_peerpoke: Peer '1002' is now Reachable. (6ms / 2000ms)
    -- Registered SIP '1001' at 192.168.1.103:14448
[Sep  2 10:32:54] ERROR[747][C-00000001]: netsock2.c:305 ast_sockaddr_resolve: getaddrinfo("raspbx", "(null)", ...): Temporary failure in name resolution
[Sep  2 10:32:54] WARNING[747][C-00000001]: acl.c:835 resolve_first: Unable to lookup 'raspbx'
[Sep  2 10:32:59] ERROR[747][C-00000001]: netsock2.c:305 ast_sockaddr_resolve: getaddrinfo("A.ROOT-SERVERS.NET", "(null)", ...): Temporary failure in name resolution
[Sep  2 10:32:59] WARNING[747][C-00000001]: acl.c:835 resolve_first: Unable to lookup 'A.ROOT-SERVERS.NET'
  == Using SIP RTP CoS mark 5
       > 0x104c2a48 -- Strict RTP learning after remote address set to: 192.168.1.103:14450
    -- Executing [1002@PA:1] Dial("SIP/1001-00000001", "SIP/1002,20") in new stack
[Sep  2 10:33:04] ERROR[774][C-00000001]: netsock2.c:305 ast_sockaddr_resolve: getaddrinfo("raspbx", "(null)", ...): Temporary failure in name resolution
[Sep  2 10:33:04] WARNING[774][C-00000001]: acl.c:835 resolve_first: Unable to lookup 'raspbx'
[Sep  2 10:33:09] ERROR[774][C-00000001]: netsock2.c:305 ast_sockaddr_resolve: getaddrinfo("A.ROOT-SERVERS.NET", "(null)", ...): Temporary failure in name resolution
[Sep  2 10:33:09] WARNING[774][C-00000001]: acl.c:835 resolve_first: Unable to lookup 'A.ROOT-SERVERS.NET'

The issue is because it is unable to resolve the name, the fix is edit /etc/hosts file

vim /etc/hosts

so default /etc/hosts file content may look like this

127.0.0.1       localhost.localdomain           localhost

Add one more line

127.0.0.1       localhost.localdomain           raspbx

The raspbx can be changed with whatever mentioned in the error acl.c:835 resolve_first: Unable to lookup ‘raspbx’