Laravel 11 cannot connect to Redis (serverless) - Checking points

 If you are having trouble connecting to Redis server (usually AWS, other cloud platform applied as well), here are some of my tested ideas to check.

All points are valid as of this writing, under Laravel 11 (Using Nginx + php-fpm, all dockerize), and build/executed in AWS ECS

  • As of this writing(5 Jul 2024), please use REDIS_CLIENT = phpredis.  predis did not work.  It will not able to connect to your AWS redis (serverless) server.  Yet it works if you setup in your local development
  • In my setting, REDIS_CLUSTER = rediss (double s), before that default value is `redis`
  • There are 3 array sections: default, cache and session
    • default: according to this git comment, this is for "normal" server.  I guess it means standalone server.  Which means the settings under default is for normal server.
    • cache: These settings are for cluster.  I found that serverless = cluster.
    • session: These settings are for sessions, if you are saving session data in redis
  • In other words, you cannot assume that setting in "default" will be applied to "cache" and "session".  They are not.  Do not make this assumption.
  • TCP/TLS: AWS requires TLS connection if you want to connect to AWS serverless server.  To set TLS, you must apply `'scheme' => env('REDIS_SCHEME', 'tls'),` to each of the arrays (default, cache, session).
  • Here is my setting:
  • As you cna see, under default, cache and session, they all have "scheme" settings, which did not exist in fresh install laravel.  You need to add it manually by yourself.
Hope it helps someone.


Comments

Popular posts from this blog

TCPDF How to show/display Chinese Character?

How to fix fancy box/Easy Fancybox scroll not work in mobile

Wordpress Load balancing: 2 web servers 1 MySQL without any Cloud services