Exit Code 127: Command Not Found

A script, CI job, or container ends with 'exit status 127'. That number has one specific meaning: the shell couldn't find the command it was told to run. Here's how to track down which command, and why.

BytExplorer 5 min read July 19, 2026

Your script, CI pipeline, or container stops and reports:

exit status 127

or in a log:

/bin/sh: 1: yourcommand: not found

Exit code 127 has a precise meaning in the shell: command not found. The shell was asked to run something and couldn't locate an executable by that name. Nothing crashed — the command never started.

The usual causes

  • A typo in the command name (pyhton, dokcer, nom).
  • The program isn't installed on this machine or image.
  • It's installed but not on PATH — the shell searches the directories in PATH and yours isn't one of them. See fixing your PATH.
  • In Docker/CI: the binary simply isn't in the image. Minimal base images (alpine, -slim) often lack bash, curl, make, or the tool your script assumes is there.

Step 1: Find which command failed

The line just before the 127 usually names it. Then check whether the shell can see it:

command -v yourcommand    # prints a path if found, nothing if not
which yourcommand

No output means the shell can't find it — that's your 127.

Step 2: Fix by cause

  • Typo → correct the spelling.
  • Not installed → install it (apt install …, pip install …, add it to your Dockerfile).
  • On PATH but not found → confirm the install directory is in PATH, or call it by full path.
  • Docker → add the package to the image, or switch to a base image that includes it:
RUN apt-get update && apt-get install -y --no-install-recommends curl

Its sibling codes

127 travels with a couple of relatives worth knowing:

  • 126 — the file was found but not executable (missing +x, or it isn't a runnable binary).
  • 137 — the process was killed (often out-of-memory); see OOMKilled / exit code 137.

For the full map, see exit codes explained.

The checklist

  1. 127 = command not found — the command never ran.
  2. command -v <name> to confirm the shell can't see it.
  3. Typo? Not installed? Not on PATH? Missing from the container image?
  4. Fix the cause; 126 means found-but-not-executable, a different fix.

Frequently Asked Questions

What does "exit status 127" mean? The shell could not find the command it was asked to run — "command not found". The executable is misspelled, not installed, or not on the shell's PATH.

Why do I get exit code 127 in Docker but the command works on my machine? Because the binary isn't in the image. Minimal base images like alpine and -slim ship without many common tools, and the container's PATH can differ from your shell. Install the tool in your Dockerfile or use a fuller base image.

What's the difference between exit code 127 and 126? 127 means the command was not found. 126 means it was found but could not be executed — usually a missing execute permission (chmod +x) or a file that isn't actually a runnable program.

Put it into practice

Stop reading, start building

This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.

More in Troubleshooting