Title: Connection error Predis\Connection
Last modified: November 16, 2023

---

# Connection error Predis\Connection

 *  Resolved [Jora Vartanov](https://wordpress.org/support/users/ruslancic/)
 * (@ruslancic)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/)
 * Hey! I have working redis on some of my servers, which runDebian+Nginx + php7.4!
 * Now, i ahve another fresh server, that runs CentOS+Nginx+php8.1!
 * And when i try to install Redis Object Cache, via >
 * `wp plugin install redis-cache --activate` and` wp redis enable`, my site goes
   down, and i have this error in nginx logs:
 *     ```wp-block-code
       2023/11/16 13:50:38 [error] 42567#42567: *1139 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function Predis\Connection\stream_socket_client() in /var/www/example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php:108
       Stack trace:
       #0 /var/www/example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(184): Predis\Connection\StreamConnection->createStreamSocket()
       #1 /var/www/example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(83): Predis\Connection\StreamConnection->unixStreamInitializer()
       #2 /var/www/example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/AbstractConnection.php(80): Predis\Connection\StreamConnection->createResource()
       #3 /var/www/example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(230): Predis\Connection\AbstractConnection->connect()
       ```
   
 * Can you help me with this? Thx in advance!

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Support [Julie](https://wordpress.org/support/users/julieadrienne/)
 * (@julieadrienne)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17207565)
 * Can you try using PhpRedis instead?
 *     ```wp-block-code
       define('WP_REDIS_CLIENT', 'phpredis');
       ```
   
 *  Thread Starter [Jora Vartanov](https://wordpress.org/support/users/ruslancic/)
 * (@ruslancic)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17207584)
 * Have been tryed! This is my configuration:
 *     ```wp-block-code
       define( 'WP_REDIS_CLIENT', 'phpredis' );
       define( 'WP_REDIS_SCHEME', 'unix' );
       define( 'WP_REDIS_PATH', '/var/run/redis/redis.sock' );
       define( 'WP_REDIS_DATABASE', 0 );
       ```
   
 *     ```wp-block-code
       Stack trace:
       #0 /var/www/www.example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(154): Predis\Connection\StreamConnection->createStreamSocket()
       #1 /var/www/www.example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(80): Predis\Connection\StreamConnection->tcpStreamInitializer()
       #2 /var/www/www.example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/AbstractConnection.php(80): Predis\Connection\StreamConnection->createResource()
       #3 /var/www/www.example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(230): Predis\Connection\AbstractConnection->connect()
       #4 /var/www/www.example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(225): Predis\Connection\StreamConnection->connect()
       #5 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/class-predis.php(127): Predis\Client->connect()
       #6 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/class-plugin.php(596): Rhubarb\RedisCache\Predis->connect()
       #7 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/ui/tabs/overview.php(16): Rhubarb\RedisCache\Plugin->check_redis_connection()
       #8 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/ui/class-tab.php(167): include('...')
       #9 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/ui/settings.php(60): Rhubarb\RedisCache\UI\Tab->display()
       #10 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/class-plugin.php(204): require_once('...')
       #11 /var/www/www.example/www/wp-includes/class-wp-hook.php(324): Rhubarb\RedisCache\Plugin->show_admin_page()
       #12 /var/www/www.example/www/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
       #13 /var/www/www.example/www/wp-includes/plugin.php(517): WP_Hook->do_action()
       #14 /var/www/www.example/www/wp-admin/admin.php(259): do_action()
       #15 /var/www/www.example/www/wp-admin/options-general.php(10): require_once('...')
       #16 {main}
         thrown
       ```
   
    -  This reply was modified 2 years, 6 months ago by [Jora Vartanov](https://wordpress.org/support/users/ruslancic/).
    -  This reply was modified 2 years, 6 months ago by [Jora Vartanov](https://wordpress.org/support/users/ruslancic/).
 *  Plugin Support [Julie](https://wordpress.org/support/users/julieadrienne/)
 * (@julieadrienne)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17207649)
 * Thanks for testing that. I looks like your PHP installation is missing the the`
   Sockets` extension: [https://www.php.net/manual/en/intro.sockets.php](https://www.php.net/manual/en/intro.sockets.php)
 * Are you managing the server yourself, or do you use a managed hosting provider?
 *  Thread Starter [Jora Vartanov](https://wordpress.org/support/users/ruslancic/)
 * (@ruslancic)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17207653)
 * Is my server, self managment!
 *  Plugin Support [Julie](https://wordpress.org/support/users/julieadrienne/)
 * (@julieadrienne)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17207678)
 * In that case, depending how you install PHP, you may need to recompile it with
   the **`--enable-sockets`** flag: [https://stackoverflow.com/questions/6137823/fatal-error-call-to-undefined-function-socket-create](https://stackoverflow.com/questions/6137823/fatal-error-call-to-undefined-function-socket-create)
 * Sockets are needed to allow the PHP process to communicate with Redis Server.
 *  Thread Starter [Jora Vartanov](https://wordpress.org/support/users/ruslancic/)
 * (@ruslancic)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17210873)
 * Hi again! My PHP installation have sockets enabled!
    1. Using another plugin, connection to redis was succesifuly, and all working good(
       i want this plugin).
    2. using `php -m | grep sockets`, i got: **sockets**,
    3. I think, the problem is not the sockets!
    4. Thx in advance!
 *  -  This reply was modified 2 years, 6 months ago by [Jora Vartanov](https://wordpress.org/support/users/ruslancic/).
 *  Thread Starter [Jora Vartanov](https://wordpress.org/support/users/ruslancic/)
 * (@ruslancic)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17210969)
 * HI! I found the answer to the first problem! These were the permissions I had
   to give to redis, using the command `usermod -a -G redis username`.
   Now the plugin
   works, I see the statistics, from the` redic-cli monitor `I see the traffic, 
   I see everything, the only problem is that I can’t access the plugin’s main page!
   Here are two screenshots:
 * Working dshboard!
 * ![](https://i0.wp.com/i.postimg.cc/8kBjdzp0/Screenshot-2023-11-17-214047.png?
   ssl=1)
 * ![](https://i0.wp.com/i.postimg.cc/2SxsTgbm/screenshot-348.png?ssl=1)
 *     ```wp-block-code
       2023/11/17 20:46:21 [error] 7981#7981: *106 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function Predis\Connection\stream_socket_client() in /var/www/example.com/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php:108
       Stack trace:
       #0 /var/www/example.com/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(184): Predis\Connection\StreamConnection->createStreamSocket()
       #1 /var/www/example.com/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(83): Predis\Connection\StreamConnection->unixStreamInitializer()
       #2 /var/www/example.com/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/AbstractConnection.php(80): Predis\Connection\StreamConnection->createResource()
       #3 /var/www/example.com/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(230): Predis\Connection\AbstractConnection->con" while reading upstream, client: 185.285.171.62, server: example.com.it, request: "GET /wp-admin/options-general.php?page=redis-cache HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/example.com.it.sock:", host: "www.example.com.it", referrer: "https://www.example.com.it/wp-admin/index.php"
       ```
   
 * > Server configuration:
   > Linux CentOS 8;
   > Nginx 1.23;
   > Percona MySQL;
   > PHP-FPM 8.1;
   > Redis server v=6.0.20 malloc=jemalloc-5.1.0 bits=64 build=8d6796f46240ad60
    -  This reply was modified 2 years, 6 months ago by [Jora Vartanov](https://wordpress.org/support/users/ruslancic/).
    -  This reply was modified 2 years, 6 months ago by [Jora Vartanov](https://wordpress.org/support/users/ruslancic/).
    -  This reply was modified 2 years, 6 months ago by [Jora Vartanov](https://wordpress.org/support/users/ruslancic/).
 *  Plugin Support [Julie](https://wordpress.org/support/users/julieadrienne/)
 * (@julieadrienne)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17211064)
 * That’s odd. Maybe it’s a bug in the [Predis library](https://github.com/predis/predis).
 * Can you create a test file called `socket-test.php` with this content:
 *     ```wp-block-code
       <?php
       var_dump(function_exists('stream_socket_client'));
       ```
   
 * And then request it via CLI or HTTP and post the output here?
 *  Thread Starter [Jora Vartanov](https://wordpress.org/support/users/ruslancic/)
 * (@ruslancic)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17211073)
 * > Can you create a test file called `socket-test.php` with this content:
 * An interesting thing!
   Using HTTP Request, from browser(`https://www.ex.com/socket-
   test.php`), I get: `bool(**false**),`Using `wp eval-file socket-test.php`, I 
   get: `bool(**true**)`;
 *  Plugin Support [Julie](https://wordpress.org/support/users/julieadrienne/)
 * (@julieadrienne)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17216000)
 * That means that your PHP version running in FPM doesn’t have the `sockets` extension
   compiled.
 *  Thread Starter [Jora Vartanov](https://wordpress.org/support/users/ruslancic/)
 * (@ruslancic)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17216081)
 * > That means that your PHP version running in FPM doesn’t have the `sockets` 
   > extension compiled.
 * But, im conected to redis with your plugin, and i recieved data, and is working
   good! The only problem is you dashboard… And how to check if my php have been
   coompiled with sockets?
 *  Plugin Support [Julie](https://wordpress.org/support/users/julieadrienne/)
 * (@julieadrienne)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/#post-17219764)
 * Aaaahh, I understand. Can you post your diagnostics from _Settings > Redis_?
 *  Thread Starter [Jora Vartanov](https://wordpress.org/support/users/ruslancic/)
 * (@ruslancic)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/page/2/#post-17219839)
 * > [Julie](https://wordpress.org/support/users/julieadrienne/)
   > (@julieadrienne)
   >  Aaaahh, I understand. Can you post your diagnostics from _Settings > Redis_?
 * ![](https://i0.wp.com/i.postimg.cc/2SxsTgbm/screenshot-348.png?ssl=1)
 *  Plugin Support [Julie](https://wordpress.org/support/users/julieadrienne/)
 * (@julieadrienne)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/page/2/#post-17222745)
 * We’ll fix this in an update this week 👍

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Connection error Predis\Connection’ is closed to new replies.

 * ![](https://ps.w.org/redis-cache/assets/icon-256x256.gif?rev=2568513)
 * [Redis Object Cache](https://wordpress.org/plugins/redis-cache/)
 * [Support Threads](https://wordpress.org/support/plugin/redis-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/redis-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redis-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redis-cache/reviews/)

## Tags

 * [predis](https://wordpress.org/support/topic-tag/predis/)

 * 17 replies
 * 2 participants
 * Last reply from: [Julie](https://wordpress.org/support/users/julieadrienne/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/connection-error-predisconnection/page/2/#post-17222745)
 * Status: resolved