Zombie jobs are stuck or inactive tasks that remain in the processing queue, potentially causing delays or interruptions for legitimate jobs. Clearing these ensures smoother operations and restores normal job processing.
Step 1: SSH Into the Server
Before running any commands, access the server using SSH. Ensure that your network security settings allow SSH access:
- Locate your EC2 instance in the AWS Console.
- Click Connect.
- Click the link to your instance's Security group to view or update inbound rules.

Make sure the correct ports (usually port 22 for SSH) are open for your IP address.
Step 2: Clear Zombie Jobs Using Docker and Artisan
Once connected to your server, run the following commands to clear zombie jobs from the project_0 queue:
sh
Enter the running wesapi container
docker exec -it $(docker ps | grep wesapi | awk '{print $1}') bash
Clear the zombie jobs from the queue
php artisan queue:clear redis --queue=project_0

Tip: Replace project_0 with the name of the queue if your setup uses a different queue.
Bulk clear queues:
echo "Pausing Horizon..."
php artisan horizon:pause
# List of queues
QUEUES=(
default
prod
project_0
project_1
project_2
project_3
project_4
project_5
project_6
project_7
project_8
project_9
project_10
project_11
project_12
project_13
project_14
project_15
project_16
project_17
project_18
project_19
)
echo "Clearing queues..."
for QUEUE in "${QUEUES[@]}"
do
echo "Clearing $QUEUE"
php artisan horizon:clear --queue=$QUEUE
done
echo "Restarting Horizon..."
php artisan horizon:terminate
echo "Done."
Sources: https://chatgpt.com/c/69a7384f-90d0-8333-82f5-f43de7dd248f
➜ Desktop ssh -i pabzwes.pem ec2-user@18.234.99.218
, #_
~\_ ####_ Amazon Linux 2023
~~ \_#####\
~~ \###|
~~ \#/ ___ https://aws.amazon.com/linux/amazon-linux-2023
~~ V~' '->
~~~ /
~~._. _/
_/ _/
_/m/'
[ec2-user@ip-172-31-84-66 ~]$ docker ps -a
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.44/containers/json?all=1": dial unix /var/run/docker.sock: connect: permission denied
[ec2-user@ip-172-31-84-66 ~]$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a845cce3181e 985542660797.dkr.ecr.us-east-1.amazonaws.com/edgarallan/wesapache-staging "apache2ctl -D FOREG…" 45 minutes ago Up 45 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp ecs-awseb-WesDockerStaging-mjn3wnjmmr-303-wesapache-staging-b4a2bcd4d8f19cf1f501
32dab219cab0 985542660797.dkr.ecr.us-east-1.amazonaws.com/edgarallan/wessocket-staging "docker-entrypoint.s…" 45 minutes ago Up 45 minutes 0.0.0.0:6001->6001/tcp, :::6001->6001/tcp ecs-awseb-WesDockerStaging-mjn3wnjmmr-303-wessocket-staging-b0f8a0ddeddde8ce7200
2050f7aea076 985542660797.dkr.ecr.us-east-1.amazonaws.com/edgarallan/wesapi-staging "tini -- /bin/bash /…" 45 minutes ago Up 45 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 9000/tcp ecs-awseb-WesDockerStaging-mjn3wnjmmr-303-wesapi-staging-ccc9f8e5be978aa4cc01
1a14a41c2fb0 985542660797.dkr.ecr.us-east-1.amazonaws.com/edgarallan/wesreact-staging "/docker-entrypoint.…" 45 minutes ago Up 45 minutes 80/tcp, 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp ecs-awseb-WesDockerStaging-mjn3wnjmmr-303-wesreact-staging-d09393c3fbe8daaa4f00
716d48f36f03 amazon/amazon-ecs-agent:latest "/agent" 2 hours ago Up 2 hours (healthy) ecs-agent
[ec2-user@ip-172-31-84-66 ~]$ docker exec -it 2050f7aea076 /bin/sh
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.44/containers/2050f7aea076/json": dial unix /var/run/docker.sock: connect: permission denied
[ec2-user@ip-172-31-84-66 ~]$ sudo docker exec -it 2050f7aea076 /bin/sh
#
#
# pwd
/var/www/html
#
# php artisan queue:clear