Asterisk logoIt's not often that I have to restart a Asterisk VoIP PBX. I recently upgraded to the latest version of Asterisk 1.4. After the installation was complete, I restarted the service and everything appeared to be functioning OK. Processes were running and owned by the asterisk user. When I tried to connect to the running asterisk (asterisk -r) with a non-superuser account, I got the following message:

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

The control file (/var/run/asterisk/asterisk.ctl) did exist, but I wasn't able to write to it:

$ cd /var/run/asterisk/
$ ls -l asterisk.ctl
srwxr-xr-x 1 asterisk asterisk 0 Mar 23 00:23 asterisk.ctl

My user was part of the asterisk group, but needed write permission in order to connect to the running asterisk server.

The fix:

$ sudo chmod g+w asterisk.ctl
$ asterisk -r
Asterisk 1.4.30, Copyright (C) 1999 - 2010 Digium, Inc. and others.
Created by Mark Spencer 
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.
=====================================================================
  == Parsing '/etc/asterisk/extconfig.conf': Found
Connected to Asterisk 1.4.30 currently running on asterisk (pid = 29432)
Verbosity is at least 3
asterisk*CLI>

Further reading: Asterisk: The Definitive Guide