Elastic Beanstalk Deployments Failing - Amazon Linux 2/3.1.5


Hi all,

We have been experiencing constant failing deployments on Elastic Beanstalk using CodePipeline.
Elastic Beanstalk Environment:

  • Platform PHP 7.4
  • Amazon Linux 2/3.1.5

We having a Symfony application running with a few cron jobs, during every deploy with CodePipeline the deployment fails with the following error message:

2021/02/12 19:16:54.089661 Executing instruction: stop php-fpm
2021/02/12 19:16:54.089672 Running command /bin/sh -c systemctl show -p PartOf php-fpm.service
2021/02/12 19:16:54.094043 Running command /bin/sh -c systemctl stop php-fpm.service
2021/02/12 19:16:54.204134 Executing instruction: FlipApplication
2021/02/12 19:16:55.339260 An error occurred during execution of command [app-deploy] - [FlipApplication]. Stop running the command. Error: remove current dir failed: unlinkat /var/app/current: directory not empty

2021/02/12 19:16:55.339271 Executing cleanup logic
2021/02/12 19:16:55.339344 CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1613157415,"severity":"ERROR"}]}]}

After the fail, retrying the deploy through CodePipeline works as expected.
We have tried killing all cron jobs prior to deploying, different folder permission, etc but the issue still persists.

Any guidance would be appreciated.

Edited by: socialRanvir on Feb 16, 2021 2:33 AM

asked 3 years ago5666 views
8 Answers

I ran the command eb deploy 1st time with the same error as you.
However, I tried running eb deploy again for the second time and it didn't appear.
If you know why, please share it with me.

answered 3 years ago

It happens to us each deploy, did it only affect you once?

answered 3 years ago

It's happening to our application as well and as far as we can tell it happens every time we deploy using aws elasticbeanstalk instead of the eb deploy command.

The way we have it set up is;

  • commit code to Gitlab
  • Gitlab runner starts up with aws-cli installed
  • aws s3 uploads the build to S3
  • aws elasticbeanstalk create-application-version creates a new application to deploy
  • aws elasticbeanstalk update-environment will deploy the application, which will fail with the error;
    [ERROR] An error occurred during execution of command [app-deploy] - [FlipApplication]. Stop running the command. Error: remove current dir failed: unlinkat /var/app/current: directory not empty

This error does not occur when you use eb deploy \[application].

Interested to know what's going on here.

answered 3 years ago

Bump, anyone else?

answered 3 years ago


Any movement on this? I am experiencing the same issue, we are using: PHP 7.4 running on 64bit Amazon Linux 2/3.1.6
We are using the GitHub source integration in a CodePipeline so no manual commands being used to trigger the deploy, all whatever AWS does under the hood.


answered 3 years ago

This issue for me was because I was mounting EFS to a directory in /var/app/current/. Heres a related answer on stack overflow https://stackoverflow.com/a/67494984/15900388, might be helpful to some.

Edited by: wesleyhendon on May 12, 2021 6:12 AM

answered 3 years ago

Same issue..

answered 3 years ago

Same issue here. It has been happening for months but is becoming more frequent. Seems totally random, we can have multiple successes in a row with no problem and also have single/multiple failures despite no changes other than re-attempting the deployment.

Amazin Linux 2/3.2.4
Ruby 2.7 running on 64bit
Rails 6
Using the eb deploy command

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions