Getaddrinfo failed: Name or service not known

Hi all,

Installing freepbx 2.7 over asterisk 1.4.30 on debian lenny 5.0 (2.6.26-2-xen-amd64 kernel) I have issues with freepbx connecting to asterisk. The status web site show Asterisk in red in the Server Status section and in the Notices appear the follorwing error:

retrieve_conf failed, config not applied
Reload failed because FreePBX could not connect to the asterisk manager interface. (freepbx.RCONFFAIL)

Whenever I try to apply changes, it returns
"Reload failed because FreePBX could not connect to the asterisk manager interface."

with following data

exit: 0
Checking for PEAR DB…OK
Checking for PEAR Console::Getopt…OK
Checking for /etc/amportal.conf …OK
Bootstrapping /etc/amportal.conf …OK
Parsing /etc/amportal.conf …OK
Parsing /etc/asterisk/asterisk.conf …OK
Connecting to database…OK
Connecting to Asterisk manager interface…OK
Warning: Invalid argument supplied for foreach() in /var/www/rack1.adamvozip.es/htdocs/admin/modules/callforward/functions.inc.php on line 64
Warning: Invalid argument supplied for foreach() in /var/www/rack1.adamvozip.es/htdocs/admin/modules/findmefollow/functions.inc.php on line 31
Warning: Invalid argument supplied for foreach() in /var/www/rack1.adamvozip.es/htdocs/admin/modules/donotdisturb/functions.inc.php on line 47
Added to globals: ASTETCDIR = /etc/asterisk
Added to globals: ASTMODDIR = /usr/lib/asterisk/modules
Added to globals: ASTVARLIBDIR = /var/lib/asterisk
Added to globals: ASTAGIDIR = /var/lib/asterisk/agi-bin
Added to globals: ASTSPOOLDIR = /var/spool/asterisk
Added to globals: ASTRUNDIR = /var/run/asterisk
Added to globals: ASTLOGDIR = /var/log/asterisk
Added to globals: CWINUSEBUSY = true
Added to globals: AMPMGRUSER = ***
Added to globals: AMPMGRPASS = ***
Added to globals: AMPDBENGINE = mysql
Added to globals: AMPDBHOST = localhost
Added to globals: AMPDBNAME = asterisk
Added to globals: AMPDBUSER = ***
Added to globals: AMPDBPASS = ***
Notice: no Devices defined
Notice: no Queues defined
Notice: no Conferences defined
Notice: no Parking Lots defined
Notice: no sip trunks defined
Notice: no iax trunks defined
Notice: no AMP Users defined
Please update your modules and reload Asterisk by visiting http://re.mo.ved.IP/admin
1 error(s) occurred, you should view the notification log on the dashboard or main screen to check for more details.

I have verified manager connection and passwords are right (manager.conf and amportal.conf+./apply_conf) and doing ngrep on port 5038 show authentication successful and few commands exchange.

In the apache log appears the following line:
[Wed Apr 21 09:10:18 2010] [error] [client re.mo.ved.IP] Wed, 21 Apr 2010 09:10:18 +0000 - Unable to connect to manager localhost:5038 (0): php_network_getaddresses: getaddrinfo failed: Name or service not known, referer: http://re.mo.ved.IP/admin/config.php
sh: asterisk: command not found

Can anyone provide any hint where the error can be?

Sorry for the long post,
Samuel

There was a problem in the fsockopen call of the file php-asmanager.php around line 256. If I manually set 127.0.0.1 in the server parameter, everything worked. But using localhost didn’t although in the /etc/hosts there is the mapping between localhost and 127.0.0.1.

The workaround has been to define the next parameter
ASTMANAGERHOST=127.0.0.1
in amportal.conf and everything seems as working perfectly…

hope it helps,
Samuel