Repository navigation
Description
I think I have not yet encountered this myself, but I believe any jobs on self-hosted GitHub runners are subject to get this error due to the race condition between the runner agent and GitHub.
This isn't specific to actions-runner-controller and I believe it's an upstream issue. But I'd still like to gather voices and knowledge around it and hopefully find a work-around.
Please see the related issues for more information.
- Ephemeral (single use) runner registrations runner#510
- Hosted agent "lost communication with the server" microsoft/azure-pipelines-agent#2261
- Self hosted runners for GitHub actions fail very often on apache/airflow#14337
- Self hosted runner in Linux container exits job prematurely runner#921 (comment)
This issue is mainly to gather experiences from whoever has been affected by the error. I appreciate it if you could share your stories, workarounds, fixes, etc. around the issue so that it would ideally be fixed upstream or in actions-runner-controller.
Verifying if you're affected by this problem
Note that the error can also happen when:
- The runner container got OOM-killed due to that your runner pod has insufficient resource. Set higher resource requests/limits.
- The runner container got OOM-killed due to that your node has insufficient resource and your runner pod had low priority. Use a more resourceful machine as your node.
If you encounter the error even after tweaking your pod and node resources, it is likely that it's due to the race between the runner agent and GitHub.
Information
- Even GitHub support seems to say that stopping the runner and using
--onceare the goto solutions. But I believe both are subject to this race condition issue.
Possible workarounds
- Disabling ephemeral runners (Ephemeral Runner: Can we make this optional? #457) (i.e. removing the
--onceflag fromrun.sh) may "alleviate" this issue, but not completely. - Don't use ephemeral runners and stop runners only in the maintenance window you've defined, while telling your colleagues to not run jobs while in the maintenance window. (The downside of this approach is that you can't rolling-update runners outside of the maintenance window
- Restart the whole workflow run whenever any job in it failed (Note that we can't retry individual job on GitHub Actions today)
Activity
jwalters-gpsw commentedon Apr 22, 2021
mumoshu commentedon Apr 22, 2021
jwalters-gpsw commentedon Apr 23, 2021
feat: Workflow job based ephemeral runner scaling (#721)
shreyasGit commentedon Jun 20, 2022
is this issue resolved now? we are still getting this for self-hosted runners on Linux box?
mumoshu commentedon Jun 20, 2022
@shreyasGit Hey. First of all, this can't be fixed 100% by ARC alone. For example, if you use EC2 spot instances for hosting self-hosted runners, it's unavoidable (as we can't block spot termination). ARC has addressed all the issues related to this so you'd better check your deployment first and think if it's supposed to work without the communication lost error.
Also, fundamentally this can be said as an issue in GitHub Actions itself, as it doesn't have any facility to auto-restart jobs that disappeared prematurely. Would you mind considering submitting a feature request to GitHub too?
DerekTBrown commentedon Sep 14, 2022
Are there ways that
actions-runner-controlleroractions-runnercould more gracefully handle the OOM-killed case? Could we somehow report OOM kills to the GitHub UI? Could we run a separate OOM killer inside the workers to kill the workflow before it exceeds memory limits?mumoshu commentedon Sep 15, 2022
@DerekTBrown Hey. I think that's fundamentally impossible. Even if we were able to hook into the host's system log to know about which process got OOM killed, we have no easy way to correlate it with a process within a container in a pod and even worse, GitHub Actions doesn't provide an API to "externally" set a workflow job status.
However, I thought you could still see a job times out after 10 minutes or so and the job that was running when the runner disappeared (due to whatever reason like OOM) was eventually marked as failed(although without an explicit error message at all). Would that be enough?
alyssaruth commentedon Jul 28, 2023
Really appreciate this! ❤️
We currently see this occasionally - from our stats it's ~2.5% of builds of our main CI/CD pipeline. Our setup is that we're using
actions-runner-controllerwithin GKE, and the nodes that the runners get spun up on are Spot VMs. We do this because it's a massive cost saving - however, it inevitably means sometimes we bump into this error when a node that's hosting a runner gets taken away from us by Google.Even outside of Spot VMs, there are all sorts of other imaginable reasons that are hard or impossible to mitigate - e.g. node upgrades, OOM kills and suchlike. The dream for us would be for jobs affected by this to automatically restart from the beginning, provisioning a fresh runner and going again.
nsheaps commentedon Aug 28, 2023
@alyssa-glean for re-running, I'd recommend a workflow that runs on completion of the specific workflows you want (can use a cloud hosted or self-hosted runner for this) which re-triggers the job. We've been doing that at my place-of-work and it works great
As for
lost communicationerrors, for us, this was mainly caused by custom timeout logic within our github actions workflows, which attempted to disable job control, then use the process group ID to determine which process to kill when the timeout expires. We've since changed this to using the linux nativetimeoutcommand with job control and the problem has mostly resolved itself, except for some cases when github itself is having issues.As for
runner shutdownerrors, this has been fully mitigated for us by the graceful termination suggestions here. This has been confirmed by both the logs on the runner (which we export to ensure we still have them after the pod dies, by building a custom image that has fluentd in it which pipes the runner logs, runner worker logs, and the actions runner daemon to stdout), and prometheus metrics, which we send to datadog.What didn't work is setting the pod label
cluster-autoscaler.kubernetes.io/safe-to-evict=false, it seemed to have no effect (at least on EKS)As for other general termination behavior, we've noticed our longer running jobs that utilize docker in docker/dind as a sidecar do not terminate gracefully. The system logs and metrics do note that a termination signal is sent, and the runner pod successfully waits. However, the default behavior of the container runtime/kubernetes is to send the termination signal to the main process on all containers in a pod, including docker-in-docker. This kills the docker daemon and causes the tests to fail when the autoscaler decides that the pod should be terminated (which we haven't really figured out why it's happening in the first place). For us this equates to failures on ~13% of our job runs for these tests. It'd be nice for the sidecar to only get terminated if the runner itself is also exited, similar to the idea here. For now, my best idea (without adding more custom stuff to the image) would be to include dind in the runner container, rather than as a sidecar.
EDIT: The dind container DOES have that termination mechanism but the docs don't suggest how to set it properly. I peeked in the CRD and found the right way to set it (
dockerEnv)signor-mike commentedon Jun 27, 2024
I downgraded Ubuntu from 22.04 LTS to 20.04 LTS and the workflow is no longer exhausting anything.
bwodecki-lf commentedon Sep 30, 2025
Hi,
Do we have any known workaround for this issue?
Sometimes my actions get stuck in the running state for a while until they eventually time out. After that, I receive an error saying that the job lost communication with the runner.
The problem usually happens when the runner is restarted due to OOM issues or other errors.
Is there any way to reconnect an action to a runner after it has been restarted?
Nikita-Guchakov commentedon Jul 17, 2026
We switched from gke to aws and same problems began.
ARC 13.x
First thing we found out that GKE internet gateway has longer idle tcp timeout, but AWS nat gateway has 350 secs. So we tweak KeepAlive settings ( send heart-beat faster ) It helped a bit, but still we still had a lot of Communication lost.
We had to increase our instances significantly, increased Listener priorities inside the container.
Again, helped a bit, but still an issue.
Still an issue for us.
Idk were to look next, but ARC should have so much problems to be cooked properly at AWS. If there is so many caveats - doc should mention them and proper WA setup, if they are unavoidable. Though still seems like some race condition or another bug for me.
Our CPUs/memory seems to have enough space, someetimes it fails at steps that doesn't require cpu/memory at all
Nikita-Guchakov commentedon Aug 24, 2026
For anyone who may have same problem: one of the biggest contributors here for us were AWS auto-scaling group a-z rebalancing enabled. You can check ASG logs to see if it rebalances nodes with the workers and disable it/deploy to single a-z
Nikita-Guchakov commentedon Sep 9, 2026
As a solution from the side of the arc Pod distribution budget for runners can be a part of installation with minAvailable: 1, so any reason for node eviction will prevent pods from be killed
marounik commentedon Oct 23, 2026
We faced the same issue: 'The self-hosted runner lost communication with the server. ... ' few times. Here is some background:
As result of this failure terraform left a lock file on S3 bucket terraform state file,
Upgrade on EKS side was completed, and after deleting the terraform lock consecutive terraform plan shows 'No changes. Your infrastructure matches the configuration'
Deployment of actions-runner-controller was done via terraform helm_release from chart version 0.23.7
Digging into this discovered some deployment configuration:
which actually matched our observation that communication was lost after about 10 minutes.
Here is our question: is this progressDeadlineSeconds relevant to the 'lost connection' ? We tried to set it to deployment with no effect, maybe helm chart needs to be fixed to propagate this timer to actual behavior of runner or controller pods.