exec format error: cannot execute binary file

A container or binary dies instantly with 'exec format error'. It almost always means the wrong CPU architecture — an amd64 image on an ARM machine, or vice versa. Here's how to spot and fix it.

BytExplorer 5 min read July 1, 2026

Your container refuses to start, or a binary won't run, with:

exec /app: exec format error

or from the shell directly:

cannot execute binary file: Exec format error

This looks like a corrupt file, but it almost never is. It means the CPU can't understand the instructions in that binary — because it was built for a different processor architecture. An amd64 (Intel/AMD) binary can't run on an arm64 chip, and vice versa. With Apple Silicon Macs and ARM cloud servers now common, this trips people up constantly.

Why it happens now

You pulled or built an image on one architecture and ran it on another:

  • An Apple Silicon Mac (arm64) pulling an image built only for amd64.
  • A CI runner that built an amd64 image, deployed to an ARM server (like AWS Graviton).
  • Copying a compiled binary from one machine to a differently-shaped one.

Step 1: Confirm the mismatch

Check your machine's architecture and the image's:

uname -m                       # your CPU: x86_64 (amd64) or aarch64 (arm64)
docker image inspect <img> --format '{{.Architecture}}'

If those two disagree, that's your answer.

Step 2: Get the right architecture

Most official images are multi-arch — pull explicitly for your platform:

docker pull --platform linux/arm64 node:22    # or linux/amd64
docker run --platform linux/arm64 node:22

Step 3: Build for the target, not your laptop

If you build the image, build for wherever it will run, which may not match your machine. buildx can target another architecture (or several):

docker buildx build --platform linux/amd64 -t myapp:amd64 .

The error is about shape, not corruption: right code, wrong CPU. Match the image's architecture to the machine that runs it — build for the server, not for your laptop.

The checklist

  1. exec format error = wrong CPU architecture, not a broken file.
  2. uname -m vs docker image inspect ... Architecture to confirm.
  3. Pull with --platform linux/<arch> to match your machine.
  4. Building? docker buildx build --platform for the target server's arch.
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