Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aom's avatar
Level 4

Issue with Laravel Horizon Daemons on Forge: Jobs Running for Both Main and Staging Sites

I'm running into an issue with Laravel Horizon while managing two sites (Main and Staging) on the same server using Laravel Forge. Each site has its own daemon configured for Horizon, but I've noticed that when a job is dispatched for the Main site, it also tries to run for the Staging site. This causes an error because the job doesn’t exist for the Staging site, leading to the message: "Job not found." It seems like the jobs are getting processed across both sites, even though they should be isolated. Has anyone encountered this issue or know of a solution to ensure that jobs for one site do not run on the other site? Any help or suggestions would be greatly appreciated!

0 likes
1 reply
LaryAI's avatar
Level 58

To address the issue of Laravel Horizon processing jobs across both your Main and Staging sites on the same server, you need to ensure that each site is using a separate queue connection and Redis database. This will isolate the job processing for each site. Here’s how you can achieve this:

  1. Separate Redis Databases: Ensure that each site is configured to use a different Redis database. You can do this by setting different REDIS_DATABASE values in the .env files for each site.

    For the Main site, in the .env file:

    REDIS_DATABASE=0
    

    For the Staging site, in the .env file:

    REDIS_DATABASE=1
    
  2. Configure Queue Connections: Define separate queue connections for each site in the config/queue.php file. You can create custom connections for each environment.

    Example configuration in config/queue.php:

    'connections' => [
        'main_site' => [
            'driver' => 'redis',
            'connection' => 'default',
            'queue' => env('MAIN_QUEUE', 'default'),
            'retry_after' => 90,
        ],
    
        'staging_site' => [
            'driver' => 'redis',
            'connection' => 'default',
            'queue' => env('STAGING_QUEUE', 'default'),
            'retry_after' => 90,
        ],
    ],
    
  3. Update Horizon Configuration: Ensure that each site’s Horizon configuration is using the correct queue connection. Update the config/horizon.php file for each site to specify the correct connection.

    For the Main site:

    'environments' => [
        'production' => [
            'supervisor-1' => [
                'connection' => 'main_site',
                'queue' => ['default'],
                'balance' => 'auto',
                'processes' => 3,
                'tries' => 3,
            ],
        ],
    ],
    

    For the Staging site:

    'environments' => [
        'staging' => [
            'supervisor-1' => [
                'connection' => 'staging_site',
                'queue' => ['default'],
                'balance' => 'auto',
                'processes' => 3,
                'tries' => 3,
            ],
        ],
    ],
    
  4. Restart Horizon: After making these changes, restart Horizon on both sites to apply the new configurations. You can do this via the command line:

    php artisan horizon:terminate
    

    This command will gracefully terminate the current Horizon processes, and they will restart automatically with the new configuration.

By following these steps, you should be able to isolate the job processing for each site, ensuring that jobs dispatched for the Main site do not run on the Staging site and vice versa.

Please or to participate in this conversation.