---
title: "CodeDeploy events stuck in Pending: agent, endpoint or slow script | Proofline"
description: "Read the lifecycle event statuses on a failed instance target: events that never leave Pending mean the agent never picked up the work."
url: https://proofline.sh/learn/codedeploy-agent-timeout/
---

[Learning center](/learn/)

# CodeDeploy events stuck in Pending: agent, endpoint or slow script

Read the lifecycle event statuses on a failed instance target: events that never leave Pending mean the agent never picked up the work. An event that started and then failed with ScriptTimedOut is a slow script, and the fix is in the revision rather than the instance.

Deployment failures The Proofline team November 22, 2026 7 min read

## The signature and its nearby causes

An EC2/on-premises deployment hangs for a long time and then fails. The deployment's `errorInformation.code` can be `TIMEOUT` (the deployment has timed out), `AGENT_ISSUE` (a problem with the CodeDeploy agent; make sure it is installed and running on all instances) or `HEALTH_CONSTRAINTS` with every lifecycle event skipped. Two different failures produce those codes. [ErrorInformation](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ErrorInformation.html) · [Error codes](https://docs.aws.amazon.com/codedeploy/latest/userguide/error-codes.html)

-   **The agent never ran the deployment.** The agent is stopped or not installed, cannot reach the CodeDeploy or S3 endpoints over HTTPS on port 443, has no credentials because the instance has no instance profile, or is rejected because the instance clock is wrong.
-   **The agent ran a script that took too long.** A hook script, or a process it started in the foreground, ran past the hook's `timeout`.

The CodeDeploy agent is needed only on the EC2/on-premises platform; ECS and Lambda deployments do not use it. [CodeDeploy agent](https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent.html)

## Read the lifecycle event statuses

Use a read-only profile and replace the uppercase placeholders. List the targets that did not succeed, then read their events. [list-deployment-targets](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-deployment-targets.html) · [get-deployment-target](https://docs.aws.amazon.com/cli/latest/reference/deploy/get-deployment-target.html)

```
aws deploy list-deployment-targets \
  --profile PROFILE --region REGION --deployment-id DEPLOYMENT_ID \
  --target-filters '{"TargetStatus":["Failed","Skipped","Pending","InProgress"]}' \
  --query 'targetIds' --output json --no-cli-pager

aws deploy get-deployment-target \
  --profile PROFILE --region REGION --deployment-id DEPLOYMENT_ID --target-id TARGET_ID \
  --query 'deploymentTarget.instanceTarget.{status:status,updated:lastUpdatedAt,events:lifecycleEvents[].{event:lifecycleEventName,status:status,start:startTime,end:endTime,code:diagnostics.errorCode,script:diagnostics.scriptName,message:diagnostics.message}}' \
  --output json --no-cli-pager
```

Each lifecycle event has a status of `Pending`, `InProgress`, `Succeeded`, `Failed`, `Skipped` or `Unknown`, and a `diagnostics.errorCode` when a script ran. The pattern across the events is the read. [LifecycleEvent](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_LifecycleEvent.html) · [Diagnostics](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_Diagnostics.html)

| Events on the instance | What it means | Next read |
| --- | --- | --- |
| The first event `Pending` with no `startTime`, the rest `Pending` | The agent never started this deployment | The agent, its network path and its credentials |
| Every event `Skipped`, deployment `HEALTH_CONSTRAINTS` | Same family; AWS lists the agent, port 443, the service role, a proxy setting, clock skew, low memory or disk, and the instance profile | The same, plus the agent log |
| `DownloadBundle` `Failed`, `UnknownError` with `not opened for reading` | The agent ran but could not read the revision from S3 | Instance profile S3 permissions and the bucket's Region |
| One event `InProgress` with a `startTime`, later `Failed` with `ScriptTimedOut` | A script ran past its `timeout` | The script and its `timeout` in the AppSpec file |
| One event `InProgress` for about an hour, then `Failed` with no script result | The agent stopped mid-event, for example because the instance was terminated | The instance's state and the agent log |

[Skipped lifecycle events](https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html#troubleshooting-skipped-lifecycle-events) · [DownloadBundle failures](https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html#troubleshooting-deployments-downloadbundle)

The last row has a documented timing. CodeDeploy gives each lifecycle event a one-hour window. If a script does not finish because the instance was terminated or the agent shut down, the deployment can take up to an hour to show `Failed`, even when the script's own timeout is shorter. If the instance is terminated between lifecycle events or before the first one starts, the timeout comes after five minutes. [Instance troubleshooting](https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-ec2-instances.html#troubleshooting-one-hour-timeout)

## When the agent never started: check the instance

Three checks cover most `Pending` and `Skipped` results. The first is an API read; the others need a session on the instance.

```
aws ec2 describe-iam-instance-profile-associations \
  --profile PROFILE --region REGION \
  --filters Name=instance-id,Values=INSTANCE_ID \
  --query 'IamInstanceProfileAssociations[].{instance:InstanceId,profile:IamInstanceProfile.Arn,state:State}' \
  --output json --no-cli-pager
```

An empty result means the instance has no instance profile. The profile grants the agent permission to communicate with CodeDeploy and to download the revision from S3. Without it, the agent log shows an error similar to `InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Missing credentials - please check if this instance was started with an IAM instance profile`. AWS says to restart the instance after attaching or correcting the profile. On-premises instances register with an IAM session ARN or user ARN instead; `aws deploy get-on-premises-instance` shows which. [Missing credentials](https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html#troubleshooting-agent-commandpoller-error) · [describe-iam-instance-profile-associations](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-iam-instance-profile-associations.html)

On the instance, check that the agent runs, then read its log. On Linux the agent log is `/var/log/aws/codedeploy-agent/codedeploy-agent.log`; on Windows Server, check the `codedeployagent` service with `Get-Service`. [Verify the agent is running](https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-verify.html) · [Agent log files](https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent.html#codedeploy-agent-revisions-logs-cleanup)

```
sudo systemctl status codedeploy-agent
sudo grep ' ERROR ' /var/log/aws/codedeploy-agent/codedeploy-agent.log | tail -n 20
```

What the log says decides the fix:

-   **No agent process.** Install or start the agent. AWS also notes the agent can stop when the instance runs low on memory or disk; lowering `max_revisions` in the agent configuration reduces the archived revisions it keeps.
-   **Connection errors.** The agent communicates outbound over HTTPS on port 443. An instance in a private subnet needs an outbound route, such as the NAT gateway AWS gives as its example, the security group must allow outbound 443, and an HTTP proxy must be set in the agent's `:proxy_uri:` setting.
-   **`InvalidSignatureException` with `Signature expired`.** The instance clock does not match the request time. Fix the instance's time synchronization.

[Agent communication](https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent.html#codedeploy-agent-outbound-port) · [Signature expired](https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-ec2-instances.html#troubleshooting-instance-time-failures)

## When a script was slow: check the AppSpec timeout

Each hook script entry takes an optional `timeout` in seconds. The default is 3,600 seconds, which is also the maximum for all scripts in one lifecycle event; if scripts exceed it, the deployment to the instance fails. Keep the sum of the `timeout` values in each event under that limit. [AppSpec hooks structure](https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html#reference-appspec-file-structure-hooks-section-structure)

AWS documents a specific trap. A script that starts a long-running process in the foreground holds the event until its timeout; AWS's example fails with `Script at specified location: after-install.sh failed to complete in 60 seconds`. Adding `&` alone does not help: the event can stay pending for up to the one-hour default and then fail. The documented fix redirects the background process's standard input, output and error to `/dev/null` so CodeDeploy can continue. [Long-running processes](https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html#troubleshooting-long-running-processes)

```
# In the hook script (a change to the revision):
/opt/orders/bin/start-worker > /dev/null 2> /dev/null < /dev/null &
```

If the script is slow for an honest reason, such as a migration or a cache warm-up, raise its `timeout` within the one-hour limit or move the work out of the deployment.

## An illustrative example: two hung deployments

These records are fictional. The deployment group `orders-prod` covers four instances.

In the first deployment, three instances succeed in minutes. The fourth, `i-0a1b2c3d4e5f60789`, shows `ApplicationStop` `Pending` with no `startTime` and every later event `Pending`, until the deployment fails. `describe-iam-instance-profile-associations` returns nothing for it: the instance was launched by hand from an old template with no instance profile. The other three instances have one. Attach the profile, restart the instance as AWS advises, and redeploy.

In the second, all four instances show `AfterInstall` `InProgress` from 10:02 and then `Failed` at 10:07 with `ScriptTimedOut`, script `scripts/warm_cache.sh`. The AppSpec gives that script `timeout: 300`. The agent ran every event up to `AfterInstall` on time, so the agent and its network path are fine. The script's run time grew with the cache, and the fix is in the revision.

## Where the statuses mislead

-   `Pending` can also mean CodeDeploy has not reached the instance yet, because the deployment configuration deploys a few instances at a time. Compare with instances in the same batch before blaming the agent.
-   Agent version matters. From version 1.5.0, the agent fails a host deployment on startup if the agent service restarted unexpectedly while running a hook script, instead of waiting out the timeout. The 2023 edition of the agent history listed 1.5.0 as the minimum supported version; check the current page before you rely on an older agent. [Agent version history](https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent.html#codedeploy-agent-version-history)
-   An instance tagged moments before the deployment may not be in it at all. AWS recommends waiting at least five minutes between tagging an instance and deploying to it.

A deployment that fails because one script errors rather than times out is covered in [the ScriptFailed guide](/learn/codedeploy-scriptfailed-lifecycle-event/), and the instance arithmetic behind `HEALTH_CONSTRAINTS` in [the health constraints guide](/learn/codedeploy-health-constraints/). The [signature table](/learn/aws-deployment-failure-signatures/) lists the matching fields for other AWS deployment services.

## Questions

### Why are all my CodeDeploy lifecycle events skipped?

The agent did not run the deployment. AWS lists the agent not installed or not running, no outbound path on port 443 to the CodeDeploy or S3 endpoints, a missing proxy setting, clock skew, low memory or disk, and a missing or under-permitted instance profile.

### Why does a CodeDeploy deployment take an hour to fail?

Each lifecycle event has a one-hour window. If the agent stops mid-event, for example because the instance was terminated, CodeDeploy can take up to that hour to mark the deployment failed, even when the script's own timeout is shorter.

### What is the maximum timeout for a CodeDeploy hook script?

3,600 seconds, which is also the default. The limit applies to all scripts in one lifecycle event together, so the sum of their `timeout` values should stay under it.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [CodeDeploy ScriptFailed: which hook, which script, which revision](/learn/codedeploy-scriptfailed-lifecycle-event/)
    
    Deployment failures The Proofline team November 22, 2026 6 min read
    
-   ### [CodeDeploy health constraints: failed instances or an impossible setting?](/learn/codedeploy-health-constraints/)
    
    Capacity overruns The Proofline team November 22, 2026 6 min read
