title: 500 Authenticating on Laravel Echo Server Class App\\Http\\Middleware\\Authenticate:api does not exist
body: <p>I'm getting an error with private channels with Laravel Echo Server.</p>
  <p>laravel-echo-server.json</p>
  <pre><code>{
          &quot;authHost&quot;: &quot;https://testapi.test.com&quot;,
          &quot;authEndpoint&quot;: &quot;/api/broadcasting/auth&quot;,
          &quot;clients&quot;: [],
          &quot;database&quot;: &quot;redis&quot;,
          &quot;databaseConfig&quot;: {
                  &quot;redis&quot;: {},
                  &quot;sqlite&quot;: {
                          &quot;databasePath&quot;: &quot;/database/laravel-echo-server.sqlite&quot;
                  }
          },
          &quot;devMode&quot;: true,
          &quot;host&quot;: null,
          &quot;port&quot;: &quot;6001&quot;,
          &quot;protocol&quot;: &quot;https&quot;,
          &quot;socketio&quot;: {},
          &quot;secureOptions&quot;: 67108864,
          &quot;sslCertPath&quot;: &quot;/etc/nginx/ssl/server.crt&quot;,
          &quot;sslKeyPath&quot;: &quot;/etc/nginx/ssl/server.key&quot;,
          &quot;sslCertChainPath&quot;: &quot;&quot;,
          &quot;sslPassphrase&quot;: &quot;&quot;,
          &quot;subscribers&quot;: {
                  &quot;http&quot;: true,
                  &quot;redis&quot;: true
          },
          &quot;apiOriginAllow&quot;: {
                  &quot;allowCors&quot;: true,
                  &quot;allowOrigin&quot;: &quot;*&quot;,
                  &quot;allowMethods&quot;: &quot;GET, POST&quot;,
                  &quot;allowHeaders&quot;: &quot;Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id&quot;
          }
  }
  </code></pre>
  <p>Env:</p>
  <pre><code>LARAVEL_ECHO_SERVER_AUTH_HOST=http://test.test
  LARAVEL_ECHO_SERVER_SSL_CERT=&quot;&quot;
  LARAVEL_ECHO_SERVER_SSL_KEY=&quot;&quot;
  LARAVEL_ECHO_SERVER_PROTO=http
  </code></pre>
  <p>Chrome shows:</p>
  <pre><code>42[&quot;subscription_error&quot;, &quot;private-user.5971&quot;, 500]
  0: &quot;subscription_error&quot;
  1: &quot;private-user.5971&quot;
  2: 500
  </code></pre>
  <p>And the log shows</p>
  <pre><code> [1:56:03 AM] - f4rbj7htL2hrRqQRAAAA could not be authenticated to private-user.5971
  {
      &quot;message&quot;: &quot;Class App\\Http\\Middleware\\Authenticate:api does not exist&quot;,
      &quot;exception&quot;: &quot;ReflectionException&quot;,
      &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php&quot;,
      &quot;line&quot;: 718,
      &quot;trace&quot;: [
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php&quot;,
              &quot;line&quot;: 718,
              &quot;function&quot;: &quot;__construct&quot;,
              &quot;class&quot;: &quot;ReflectionClass&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php&quot;,
              &quot;line&quot;: 731,
              &quot;function&quot;: &quot;Illuminate\\Routing\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Routing\\Router&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;function&quot;: &quot;Illuminate\\Support\\Traits\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Support\\Collection&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Collections/Arr.php&quot;,
              &quot;line&quot;: 664,
              &quot;function&quot;: &quot;array_filter&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Collections/Collection.php&quot;,
              &quot;line&quot;: 344,
              &quot;function&quot;: &quot;where&quot;,
              &quot;class&quot;: &quot;Illuminate\\Support\\Arr&quot;,
              &quot;type&quot;: &quot;::&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php&quot;,
              &quot;line&quot;: 733,
              &quot;function&quot;: &quot;filter&quot;,
              &quot;class&quot;: &quot;Illuminate\\Support\\Collection&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php&quot;,
              &quot;line&quot;: 723,
              &quot;function&quot;: &quot;reject&quot;,
              &quot;class&quot;: &quot;Illuminate\\Support\\Collection&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php&quot;,
              &quot;line&quot;: 685,
              &quot;function&quot;: &quot;gatherRouteMiddleware&quot;,,
              &quot;class&quot;: &quot;Illuminate\\Routing\\Router&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php&quot;,
              &quot;line&quot;: 669,
              &quot;function&quot;: &quot;runRouteWithinStack&quot;,
              &quot;class&quot;: &quot;Illuminate\\Routing\\Router&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php&quot;,
              &quot;line&quot;: 635,
              &quot;function&quot;: &quot;runRoute&quot;,
              &quot;class&quot;: &quot;Illuminate\\Routing\\Router&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php&quot;,
              &quot;line&quot;: 624,
              &quot;function&quot;: &quot;dispatchToRoute&quot;,
              &quot;class&quot;: &quot;Illuminate\\Routing\\Router&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php&quot;,
              &quot;line&quot;: 166,
              &quot;function&quot;: &quot;dispatch&quot;,
              &quot;class&quot;: &quot;Illuminate\\Routing\\Router&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php&quot;,
              &quot;line&quot;: 128,
              &quot;function&quot;: &quot;Illuminate\\Foundation\\Http\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Foundation\\Http\\Kernel&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php&quot;,
              &quot;line&quot;: 67,
              &quot;function&quot;: &quot;Illuminate\\Pipeline\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Pipeline\\Pipeline&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php&quot;,
              &quot;line&quot;: 167,
              &quot;function&quot;: &quot;handle&quot;,
              &quot;class&quot;: &quot;Barryvdh\\Debugbar\\Middleware\\InjectDebugbar&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/fideloper/proxy/src/TrustProxies.php&quot;,
              &quot;line&quot;: 57,
              &quot;function&quot;: &quot;Illuminate\\Pipeline\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Pipeline\\Pipeline&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php&quot;,
              &quot;line&quot;: 167,
              &quot;function&quot;: &quot;handle&quot;,
              &quot;class&quot;: &quot;Fideloper\\Proxy\\TrustProxies&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php&quot;,
              &quot;line&quot;: 21,
              &quot;function&quot;: &quot;Illuminate\\Pipeline\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Pipeline\\Pipeline&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php&quot;,
              &quot;line&quot;: 167,
              &quot;function&quot;: &quot;handle&quot;,
              &quot;class&quot;: &quot;Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php&quot;,
              &quot;line&quot;: 21,
              &quot;function&quot;: &quot;Illuminate\\Pipeline\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Pipeline\\Pipeline&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php&quot;,
              &quot;line&quot;: 167,
              &quot;function&quot;: &quot;handle&quot;,
              &quot;class&quot;: &quot;Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php&quot;,
              &quot;line&quot;: 27,
              &quot;function&quot;: &quot;Illuminate\\Pipeline\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Pipeline\\Pipeline&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php&quot;,
              &quot;line&quot;: 167,
              &quot;function&quot;: &quot;handle&quot;,
              &quot;class&quot;: &quot;Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php&quot;,
              &quot;line&quot;: 87,
              &quot;function&quot;: &quot;Illuminate\\Pipeline\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Pipeline\\Pipeline&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php&quot;,
              &quot;line&quot;: 167,
              &quot;function&quot;: &quot;handle&quot;,
              &quot;class&quot;: &quot;Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/app/Http/Middleware/Cors.php&quot;,
              &quot;line&quot;: 28,
              &quot;function&quot;: &quot;Illuminate\\Pipeline\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Pipeline\\Pipeline&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php&quot;,
              &quot;line&quot;: 167,
              &quot;function&quot;: &quot;handle&quot;,
              &quot;class&quot;: &quot;App\\Http\\Middleware\\Cors&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php&quot;,
              &quot;line&quot;: 103,
              &quot;function&quot;: &quot;Illuminate\\Pipeline\\{closure}&quot;,
              &quot;class&quot;: &quot;Illuminate\\Pipeline\\Pipeline&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php&quot;,
              &quot;line&quot;: 141,
              &quot;function&quot;: &quot;then&quot;,
              &quot;class&quot;: &quot;Illuminate\\Pipeline\\Pipeline&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php&quot;,
              &quot;line&quot;: 110,
              &quot;function&quot;: &quot;sendRequestThroughRouter&quot;,
              &quot;class&quot;: &quot;Illuminate\\Foundation\\Http\\Kernel&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          },
          {
              &quot;file&quot;: &quot;/home/vagrant/myproject/public/index.php&quot;,
              &quot;line&quot;: 52,
              &quot;function&quot;: &quot;handle&quot;,
              &quot;class&quot;: &quot;Illuminate\\Foundation\\Http\\Kernel&quot;,
              &quot;type&quot;: &quot;-&gt;&quot;
          }
      ]
  }
  Client can not be authenticated, got HTTP status 500
  </code></pre>
  <p>I cannot figure out why private channels will not work. Public ones do though. Any help would be great! I did do a recent upgrade to Laravel 8 from 5.7, but have since looked at another project that is in 8 which does not have any issues.</p>
  <p>Thanks!</p>
  <p>config/auth.php:</p>
  <pre><code>&lt;?php
  
  return [
  
      /*
      |--------------------------------------------------------------------------
      | Authentication Defaults
      |--------------------------------------------------------------------------
      |
      | This option controls the default authentication &quot;guard&quot; and password
      | reset options for your application. You may change these defaults
      | as required, but they're a perfect start for most applications.
      |
      */
  
      'defaults' =&gt; [
          'guard' =&gt; 'web',
          'passwords' =&gt; 'users',
      ],
  
      /*
      |--------------------------------------------------------------------------
      | Authentication Guards
      |--------------------------------------------------------------------------
      |
      | Next, you may define every authentication guard for your application.
      | Of course, a great default configuration has been defined for you
      | here which uses session storage and the Eloquent user provider.
      |
      | All authentication drivers have a user provider. This defines how the
      | users are actually retrieved out of your database or other storage
      | mechanisms used by this application to persist your user's data.
      |
      | Supported: &quot;session&quot;, &quot;token&quot;
      |
      */
  
      'guards' =&gt; [
          'web' =&gt; [
              'driver' =&gt; 'session',
              'provider' =&gt; 'users',
          ],
  
          'api' =&gt; [
              'driver' =&gt; 'passport',
              'provider' =&gt; 'users',
              'hash' =&gt; false,
          ],
      ],
  
      /*
      |--------------------------------------------------------------------------
      | User Providers
      |--------------------------------------------------------------------------
      |
      | All authentication drivers have a user provider. This defines how the
      | users are actually retrieved out of your database or other storage
      | mechanisms used by this application to persist your user's data.
      |
      | If you have multiple user tables or models you may configure multiple
      | sources which represent each model / table. These sources may then
      | be assigned to any extra authentication guards you have defined.
      |
      | Supported: &quot;database&quot;, &quot;eloquent&quot;
      |
      */
  
      'providers' =&gt; [
          'users' =&gt; [
              'driver' =&gt; 'eloquent',
              'model' =&gt; App\User::class,
          ],
  
          // 'users' =&gt; [
          //     'driver' =&gt; 'database',
          //     'table' =&gt; 'users',
          // ],
      ],
  
      /*
      |--------------------------------------------------------------------------
      | Resetting Passwords
      |--------------------------------------------------------------------------
      |
      | You may specify multiple password reset configurations if you have more
      | than one user table or model in the application and you want to have
      | separate password reset settings based on the specific user types.
      |
      | The expire time is the number of minutes that the reset token should be
      | considered valid. This security feature keeps tokens short-lived so
      | they have less time to be guessed. You may change this as needed.
      |
      */
  
      'passwords' =&gt; [
          'users' =&gt; [
              'provider' =&gt; 'users',
              'table' =&gt; 'password_resets',
              'expire' =&gt; 60,
              'throttle' =&gt; 60,
          ],
      ],
  
      /*
      |--------------------------------------------------------------------------
      | Password Confirmation Timeout
      |--------------------------------------------------------------------------
      |
      | Here you may define the amount of seconds before a password confirmation
      | times out and the user is prompted to re-enter their password via the
      | confirmation screen. By default, the timeout lasts for three hours.
      |
      */
  
      'password_timeout' =&gt; 10800,
  
  ];
  </code></pre>