"Memcache can't connect, connection refused (111)"?

8,804

Update!

So I eventually succeeded. How:

  1. Googled "see if memcached are installed command line centos5"
  2. Clicked on the third result, ended up on this page: http://cnedelcu.blogspot.se/2009/09/setting-up-and-using-memcached-memcache.html
  3. Followed the steps
  4. Succeeded to install Memcached but not Memcache:

    [root@mydomain /]# yum install php-pecl-memcache
    Loaded plugins: fastestmirror, priorities
    Loading mirror speeds from cached hostfile
    * base: centos.mirror.nac.net
    * extras: mirror.atlanticmetro.net
    * updates: centos.mirror.nac.net
    base                                                     | 1.1 kB     00:00     
    extras                                                   | 2.1 kB     00:00     
    updates                                                  | 1.9 kB     00:00     
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package php-pecl-memcache.x86_64 0:2.2.3-1.el5_2 set to be updated
    --> Processing Dependency: php-api = 20041225 for package: php-pecl-memcache
    --> Finished Dependency Resolution
    php-pecl-memcache-2.2.3-1.el5_2.x86_64 from extras has depsolving problems
      --> Missing Dependency: php-api = 20041225 is needed by package php-pecl-memcache-2.2.3-1.el5_2.x86_64 (extras)
    Error: Missing Dependency: php-api = 20041225 is needed by package php-pecl-memcache-2.2.3-1.el5_2.x86_64 (extras)
     You could try using --skip-broken to work around the problem
     You could try running: package-cleanup --problems
                            package-cleanup --dupes
                            rpm -Va --nofiles --nodigest
    The program package-cleanup is found in the yum-utils package.
    

However, seems it didn't needed to succeed. Memcache seems to work now!

Share:
8,804

Related videos on Youtube

Peter Westerlund
Author by

Peter Westerlund

Self-learned Web Developer from Stockholm, Sweden. Founder of Nonbranded.se, a store with products without visible brands.

Updated on September 18, 2022

Comments

  • Peter Westerlund
    Peter Westerlund almost 2 years

    First of all...

    I must say, I don't know much about servers. I'm the kind of php developer that don't use command lines very often. I'm very uncomfortable in the Terminal.

    However, I'm learning. I'm not used to have my websites on dedicated servers without managed hosting. But now I have it for the first time, and I need to install Memcache by my self.

    Some Server Info

    • Product: Dedicated Server (DV) on Media Temple
    • Parallels® Plesk Panel 12 or cPanel® 11
    • CentOS 5.7 (Final)
    • Apache 2.2
    • PHP 5.4
    • YUM package management

    What I've done

    I have followed this guide: https://mediatemple.net/community/products/dv/204644340/installing-pecl-extensions

    But of course with memcache instead of uploadprogress.

    And I have checked, Memcache is installed and running. And $memcache = new Memcache; is working in my php codes. But $memcache->connect('localhost', 11211); is not working. I get error message:

    Warning: Memcache::connect(): Can't connect to localhost:11211, Connection refused (111) in /var/www/vhosts/[mydomain]/httpdocs/index.php on line 10 Could not connect to memcache server
    

    And I have tried to change localhost to the server's IP number but without success.

    I have googled a lot, and ended up in articles and forum threads about installing Memcached before. So I followed one of those guides and tried to install it. But got error messages No package memcached available. so it couldn't be installed.

    Here are a sample of commands I did after that:

    Nothing to do
    [root@mydomain /]# php -i | grep memcache
    PHP Warning:  Module 'memcache' already loaded in Unknown on line 0
    /etc/php.d/memcached.ini,
    PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in Unknown on line 0
    memcache
    memcache support => enabled
    memcache.allow_failover => 1 => 1
    memcache.chunk_size => 8192 => 8192
    memcache.default_port => 11211 => 11211
    memcache.default_timeout_ms => 1000 => 1000
    memcache.hash_function => crc32 => crc32
    memcache.hash_strategy => standard => standard
    memcache.max_failover_attempts => 20 => 20
    Registered save handlers => files user memcache 
    OLDPWD => /memcached-1.4.9
    _SERVER["OLDPWD"] => /memcached-1.4.9
    [root@mydomain /]# ps aux | grep memcache
    root      6434  0.0  0.0   9288   868 pts/0    S+   02:37   0:00 grep memcache
    [root@mydomain /]# getenforce
    Disabled
    

    So...

    What did I forget to do?

    • fvu
      fvu almost 9 years
      memcache isn't running (ps doesn't return a line for the memcache daemon). Start it (and enable the service so that it gets restarted after a reboot) and then check whether memcache is actually listening on the port where you expect it to listen? netstat -alnp should return a line containing 0.0.0.0:11211 if it is.
    • fvu
      fvu almost 9 years
      I'm not much of a Centos specialist, but to enable and start the service the command should be something like chkconfig memcached on
    • Peter Westerlund
      Peter Westerlund almost 9 years
      Okey, Memcache is not running..It's installed but not running then. service memcached start doesn't work. netstat -alnp return a lot of lines and no one like that. chkconfig memcached on retured a error message that the directory doesn't exist.
    • fvu
      fvu almost 9 years
      Can you add the errors you get to the question? If chkconfig complains, something must be wrong, let's find out what :)
    • Peter Westerlund
      Peter Westerlund almost 9 years
      The errors are in Swedish. But I guess it translates like this: Error when reading information about the service memcached: File or directory does not exist
    • fvu
      fvu almost 9 years
      Hmmm... As I suspect you did not actually install the memcache server - or improperly - what is the output of yum list installed | grep memcache ? I think so because you only mention the instruction relative to the php extension needed for memcache, nowhere you mention the installation of the daemon. Plus, it's not running and trying to start it causes all kinds of odd errors.
    • fvu
      fvu almost 9 years