Unable to connect to remote asterisk (does /var/run/asterisk.ctl exist?). SOLVED

Asterisk 1.4.22.1 sets the default astrundir as /var/run, not /var/run/asterisk. This is specified in the default.h file in the installation package’s root directory. I am not sure of the situation in asterisk 1.6. This means;

  1. via the command asterisk -r you cannot connect to the asterisk CLI after installing asterisk 1.4.22.1. You get the message:
    Unable to connect to remote asterisk (does /var/run/asterisk.ctl exist?). However, you can run asterisk.

  2. after installing your asterisk as above, if you reinstall freepbx (freepbx 2.5.1 version in my case - and asterisk of course must be running to install freepbx) and run the command amportal start, you get this message:
    **** ERROR IN CONFIGURATION ****
    astrundir in /etc/asterisk/asterisk.conf is set to ‘/var/run’ - THIS IS WRONG.
    Please change it to something sensible (eg, ‘/var/run/asterisk’) and re-run install_amp

  3. You cannot stop asterisk via amportal stop. You must use the kill command after nominating the correct process to kill (which you can find via the command ps aux).

I found that the appropriate setting to change to in /etc/asterisk/asterisk.conf, under the heading [directories], was:
astrundir => /var/run/asterisk Asterisk must be restarted for the change to take effect.

I also found that asterisk 1.2 uses the heading [global] instead of the heading [directories] in asterisk 1.4, so you must also change that heading manually to [directories] if upgrading from 1.2 to 1.4 but keeping your /etc/asterisk/ files.

Hope the above helps
Michael

[root@localhost freepbx-2.5.1]# amportal start

SETTING FILE PERMISSIONS
Permissions OK

STARTING ASTERISK
Asterisk is already running

STARTING FOP SERVER
FOP server is already running
[root@localhost freepbx-2.5.1]# ./install_amp
Checking for PEAR DB…OK
Checking for PEAR Console::Getopt…OK
Checking user…OK
Checking if Asterisk is running…running with PID: 3700…OK
Checking for /etc/amportal.conf…OK
Reading /etc/amportal.conf…OK
Checking for /etc/asterisk/asterisk.conf…OK
Reading /etc/asterisk/asterisk.conf…OK
Using asterisk as PBX Engine
Checking for Asterisk version…1.4.23.2
Checking for selinux…OK
Connecting to database…OK
Checking current version of AMP…no version information
Assuming new installation
Installing new FreePBX files…OK (504 files copied, 0 skipped)
Configuring install for your environment…amportal…freepbx_engine…done
apply username/password changes to conf files…done
creating missing #include files…OK
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)
OK
Setting permissions on files…OK
Checking for upgrades…32 found
Upgrading to 1.10.007beta1…
-> Running SQL script /usr/src/freepbx-2.5.1/upgrades/1.10.007beta1/tables.sql
[FATAL] ALTER TABLE sip CHANGE id id BIGINT( 11 ) DEFAULT “-1” NOT NULL [nativecode=1146 ** Table ‘asterisk.sip’ doesn’t exist]" while running tables.sql

mehdy,

Again please don’t hijack somebody elses thread. While you might think it’s related it is not. Please post a new thread, also you’ve not provided enough info for us to help you. We can see that you are having a install problem with FreePBX 2.5.1 and are using asterisk 1.4.23.2 but past that we know nothing.

Please see http://freepbx.org/forum/freepbx/installation/so-you-have-a-problem-and-want-help

You need to provide more details and there is not even a question asked in this post.

I am running asterisk 1.6 and I changed my asterisk.conf to /var/run/asterisk and I get the same error… also when I run rasterisk -rvvv I get the same message… what am I missing?

btw: my amportal.conf also points to /var/run/asterisk

Checked op and that last post for the “!”.

I still have the “Unable to connect to remote asterisk (does /var/run/asterisk.ctl exist?)” problem.

CentOS 5.4 64bit
Asterisk 1.6.1.8
FreePBX 2.6.0.0

Directory permissions are good, log files are clean and everything seems to be working properly. I suspect it has something to do with how FPBX stops Asterisk by issuing 2 stop commands when it seems that only one is required. At least that seems to be the case for Asterisk 2.6.

This is the exact fpbx script that I believe is causing the problem.
/var/lib/asterisk/bin/freepbx_engine
stop_asterisk() {
echo
echo "STOPPING ASTERISK"
pid_length=$PIDOF asterisk|awk '{print length($0)}'
if [ “$pid_length” != “0” -a “$pid_length” != “” ]
then
/usr/sbin/asterisk -rx “core stop gracefully” | grep -v “No such command”
/usr/sbin/asterisk -rx “stop gracefully” | grep -v -E "No such command|deprecated"
echo "Asterisk Stopped"
fi
}

Michael Daly’s post at the top of this page is correct follow those instructions,
But there is one extra thing to lookout for when using Asterisk 1.6

What many people may not notice is that,
inside “/etc/asterisk/asterisk.conf”

look at the “[directories]” header itself there could be a (!) at the end of the line.
if the (!) is there then asterisk is ignoring that whole group.
remove the (!) save and restart everything and you should be good.

Hope this help
-TC
=^_^=

Folks,

I am running into the same problem here. Whenever I do amportal start, I cannot connect to the asterisk CLI by typing asterisk -r. I already modfied the path in /etc/amportal.conf to be /var/run/asterisk instead of /var/run. Has anyone found a fix to this?

The only workaround I have today is to do “service asterisk restart” in CentOS after “amportal start” and now it connects to the asterisk CLI with no issues. Below is the output:

-----begin terminal output---------

[root@freepbx ~]# amportal stop

STOPPING ASTERISK
Unable to connect to remote asterisk (does /var/run/asterisk.ctl exist?)
Asterisk Stopped

STOPPING FOP SERVER
Asterisk ended with exit status 0
Asterisk shutdown normally.
FOP Server Stopped
[root@freepbx ~]# amportal start

SETTING FILE PERMISSIONS
Permissions OK

STARTING ASTERISK
Asterisk Started

STARTING FOP SERVER
FOP Server Started
[root@freepbx ~]# asterisk -r
Asterisk 1.6.0.20, Copyright © 1999 - 2009 Digium, Inc. and others.
Created by Mark Spencer [email protected]
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.

Unable to connect to remote asterisk (does /var/run/asterisk.ctl exist?)
[root@freepbx ~]#
------end terminal output---------

this works very well for me