Skip to content

Dealing with jobs failing with "lost communication with the server" errors #466

Open

Description

@mumoshu

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.

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 --once are 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 --once flag from run.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

  1. jwalters-gpsw commented on Apr 22, 2021

    @jwalters-gpsw
  2. mumoshu commented on Apr 22, 2021

    @mumoshu
    Author
  3. jwalters-gpsw commented on Apr 23, 2021

    @jwalters-gpsw
  4. added
    documentation
    help wanted
    on May 16, 2021
  5. deleted a comment from 1818l on Oct 17, 2021
  6. shreyasGit commented on Jun 20, 2022

    @shreyasGit

    is this issue resolved now? we are still getting this for self-hosted runners on Linux box?

  7. mumoshu commented on Jun 20, 2022

    @mumoshu
    CollaboratorAuthor

    @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?

  8. DerekTBrown commented on Sep 14, 2022

    @DerekTBrown

    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.

    Are there ways that actions-runner-controller or actions-runner could 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?

  9. mumoshu commented on Sep 15, 2022

    @mumoshu
    CollaboratorAuthor

    @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?

  10. alyssaruth commented on Jul 28, 2023

    @alyssaruth

    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.

    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-controller within 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.

  11. nsheaps commented on Aug 28, 2023

    @nsheaps
    Contributor

    @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 communication errors, 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 native timeout command with job control and the problem has mostly resolved itself, except for some cases when github itself is having issues.

    As for runner shutdown errors, 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)

  12. signor-mike commented on Jun 27, 2024

    @signor-mike

    I downgraded Ubuntu from 22.04 LTS to 20.04 LTS and the workflow is no longer exhausting anything.

  13. bwodecki-lf commented on Sep 30, 2025

    @bwodecki-lf

    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?

  14. Nikita-Guchakov commented on Jul 17, 2026

    @Nikita-Guchakov

    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

  15. Nikita-Guchakov commented on Aug 24, 2026

    @Nikita-Guchakov

    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

  16. Nikita-Guchakov commented on Sep 9, 2026

    @Nikita-Guchakov

    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

  17. marounik commented on Oct 23, 2026

    @marounik

    We faced the same issue: 'The self-hosted runner lost communication with the server. ... ' few times. Here is some background:

    • We are trying to run AWS Managed Node group AMI upgrade via terraform;
    • The usual duration of AMI upgrade is between 10m and 15m and we have timeouts.update=15m for eks_managed_node_groups;
    • Runner froze and job failed with an error above.

    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:

    $ kubectl -n actions-runner-system get deployment actions-runner-controller -o yaml | yq .spec
    progressDeadlineSeconds: 600
    replicas: 1
    revisionHistoryLimit: 10
    ...
    
    

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions