Lost Connection to Build Agent Issue

Bitrise Build Issue Report template

Description of the issue

Build keeps failing due to “Lost connection to build agent” issue.


Where did the issue happen?

Step: Gradle Runner
Stack: Standard Machine, Android & Docker, on Ubuntu 20.04

Which build Step causes the issue and which version of the step?

Step: Gradle Runner
Stack : Standard Machine, Android & Docker, on Ubuntu 20.04


  • Does a “Rebuild” help? (You can trigger a rebuild from the Build’s page, by clicking the “Rebuild” button in the top right corner of a finished build) : NO
  • Does a rebuild without caches help? (You can remove the Cache:Pull and Cache:Push steps temporarily to not to use the cache, or you can delete all the caches on the Settings tab of the app. : NO
  • Does the issue happen sporadically, or every time? : YES
  • Does upgrading the build Step to the latest version help? : NO
  • When did the issue start? : 1st October 2021

Local reproduction

I use a different stack on my local machine, so it is hard to migrate all the scripts to try to reproduce the issue.

Local reproduction: Linux / Android (docker based) stack builds

Didn’t try as it requires a lot of time to setup, but will do if it is needed

Build log

Screenshot 2021-10-13 at 12.18.02

This can happen if your build is using up all the VM resources and runs out of memory.

Have you tested on the Elite VMs to see if the issue goes away?

You can SSH into the Build VM to run some checks like

top -l 3 -o cpu -n 10 -stats command,cpu,mem,time | tail -n 21


free -m

to see if that might be the issue.