124
BashERRORNotableExit CodeHIGH confidence

Command timed out

Production Risk

Expected when commands hang; always handle 124 in CI/CD pipelines.

What this means

Exit code 124 is returned by the `timeout` utility when the command it is running exceeds the specified duration and is killed.

Why it happens
  1. 1The wrapped command takes longer than the timeout duration
  2. 2A network operation stalls indefinitely
  3. 3A script hangs waiting for user input in an automated context
How to reproduce

Running a slow command with a short timeout.

trigger — this will error
trigger — this will error
timeout 2s sleep 10
echo "Exit: $?"

expected output

Exit: 124

Fix 1

Increase the timeout duration

WHEN The command normally completes but occasionally takes longer

Increase the timeout duration
timeout 60s your_command

Why this works

Increasing the timeout gives the command more time to complete legitimately.

Fix 2

Handle exit code 124 explicitly

WHEN In scripts that use timeout

Handle exit code 124 explicitly
timeout 30s curl https://example.com/api
if [ $? -eq 124 ]; then
  echo "Request timed out after 30s" >&2
  exit 1
fi

Why this works

Checking for 124 specifically lets you emit a clear error message distinct from other failures.

What not to do

Use very short timeouts without retry logic

Transient slowness will cause failures; implement retries with backoff for network operations.

Sources
Official documentation ↗

GNU coreutils — timeout

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Bash errors