adrians's avatar

Horizon

Hello everybody. Has anyone experienced that when Horizon starts craches the server? What could be? (redis server working) .Thank you.

0 likes
2 replies
kashyapH's avatar

Yes — that happens sometimes with Laravel Horizon if something in the setup isn’t right. A crash when Horizon starts usually points to one of these common issues:

  1. Redis connection overload / wrong config

    • Horizon uses Redis heavily. If your Redis connection details in config/database.php are wrong, or Redis is maxing out memory/CPU, Horizon can cause the server to choke.
    • Check Redis logs (/var/log/redis/redis-server.log) and Laravel logs (storage/logs/laravel.log).
  2. Supervisor misconfiguration (if you use it to keep Horizon alive)

    • If Supervisor is restarting Horizon too fast (e.g., config loops), it can spike CPU and crash the box.
    • Run supervisorctl status to check.
  3. Horizon dashboard polling

    • Horizon’s UI polls Redis for metrics — on a weak server (low memory or shared hosting), that can crash it.
  4. PHP memory limit

    • Horizon spawns multiple worker processes. If php.ini has a low memory limit, each worker eats memory and the server crashes.
  5. Too many Horizon workers configured

    • In config/horizon.php, check supervisor definitions. If you’ve set processes too high (like 50 on a small server), the server may run out of RAM instantly.

  • Check logs first:

    tail -f storage/logs/laravel.log
    tail -f /var/log/syslog
    tail -f /var/log/redis/redis-server.log
    
  • Lower worker count in config/horizon.php:

    'supervisors' => [
        'default' => [
            'connection' => 'redis',
            'queue' => ['default'],
            'balance' => 'auto',
            'maxProcesses' => 1,  // try small first
            'processes' => 1,
            'tries' => 3,
        ],
    ],
    
  • Restart Redis to clear stuck connections:

    sudo systemctl restart redis
    
  • Clear Horizon cache:

    php artisan horizon:clear
    
  • Test Horizon manually without Supervisor:

    php artisan horizon
    

    → If it runs, the issue is probably Supervisor configuration.


In most cases, the culprit is too many Horizon workers for the server resources. Start with just 1 worker, confirm stability, then scale up gradually.

1 like
adrians's avatar

@kashyapH Thank for your answer. The server guys fixed it (so i guess it was a serve issue), but the didn't tell me what was the problem. I'll keep in mind your advice!

Please or to participate in this conversation.