Answers.Body: <p>Luckily, someone else had this problem: <a href="https://github.com/craftcms/cms/issues/7617#issuecomment-786715807" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/7617#issuecomment-786715807</a></p>
  <p>The issue was because of leaving the password blank. devMode did not care, but production did. Had to remove the password entirely</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-03T16:04:46.690Z
Answers.LastActivityDate: 2021-04-03T16:04:46.690Z
Answers.UserDisplayName: Cat Named Dog
Body: <p>I've added this to the array that is returned in <code>config/app.php</code>:</p>
  <pre><code>'components' =&gt; [
          'redis' =&gt; [
              'class' =&gt; yii\redis\Connection::class,
              'hostname' =&gt; App::env('REDIS_HOST'),
              'port' =&gt; APP::env('REDIS_PORT'),
              'password' =&gt; ''
          ],
          'cache' =&gt; [
              'class' =&gt; yii\redis\Cache::class,
              'defaultDuration' =&gt; 86400,
              'keyPrefix' =&gt; App::env('APP_ID') ?: 'CraftCMS',
          ],
  
          'session' =&gt; function() {
              // Get the default component config
              $config = App::sessionConfig();
  
              // Override the class to use Redis' session class
              $config['class'] = yii\redis\Session::class;
  
              // Instantiate and return it
              return Craft::createObject($config);
          },
          
      ]
  </code></pre>
  <p>This all works find when my environment is in <code>dev</code> and <code>devMode</code> is on.</p>
  <p>When I switch to production, I get an internal server error. I don't know what the issue is because it doesn't give me the full logs.</p>
  
Tags: <redis>
Title: error in production when using redis for cache and session
ThreadText: # error in production when using redis for cache and session
  
  (Asked by: username_0 on 2021-04-03)
  
  I've added this to the array that is returned in `config/app.php`:
  
  ```
  'components' => [
          'redis' => [
              'class' => yii\redis\Connection::class,
              'hostname' => App::env('REDIS_HOST'),
              'port' => APP::env('REDIS_PORT'),
              'password' => ''
          ],
          'cache' => [
              'class' => yii\redis\Cache::class,
              'defaultDuration' => 86400,
              'keyPrefix' => App::env('APP_ID') ?: 'CraftCMS',
          ],
  
          'session' => function() {
              // Get the default component config
              $config = App::sessionConfig();
  
              // Override the class to use Redis' session class
              $config['class'] = yii\redis\Session::class;
  
              // Instantiate and return it
              return Craft::createObject($config);
          },
          
      ]
  
  ```
  
  This all works find when my environment is in `dev` and `devMode` is on.
  
  When I switch to production, I get an internal server error. I don't know what the issue is because it doesn't give me the full logs.
  
  **Tags:** redis
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-04-03. Score: 1
  
  Luckily, someone else had this problem: <https://github.com/craftcms/cms/issues/7617#issuecomment-786715807>
  
  The issue was because of leaving the password blank. devMode did not care, but production did. Had to remove the password entirely
  
  
  ---
  
  