"Exec Format Error" — Wrong Architecture or Corrupt Binary

The kernel can't execute the file: it's the wrong arch (ARM vs x86), a glibc/musl mismatch variant, or the file isn't actually a binary. One command classifies it.

What you'll see

Root causes

Architecture mismatch

x86-64 binary on ARM (or Apple Silicon downloads on a Linux/AMD64 host). uname -m vs file <binary> settles it in five seconds. Docker: image built for the wrong --platform.

Not a native executable at all

A Windows PE binary, a corrupt/truncated download, or a script missing its shebang — all 'exec format error' because the kernel doesn't recognize a runnable format.

Fix it

  1. Classify the file and compare architectures
    file <binary> ; uname -m   # 'ELF 64-bit ... x86-64' on aarch64 = the mismatch
  2. Get the right build
    # download the matching release artifact (linux-arm64 vs linux-amd64), or: docker build --platform linux/amd64 ... where emulation is acceptable
  3. Docker: build/pull with the explicit platform
    docker build --platform linux/arm64 -t app:arm . ; docker run --platform linux/amd64 app   # error message during run = image arch mismatch
  4. For scripts: verify the shebang line
    head -1 <script>   # #!/bin/bash missing or with CRLF = 'exec format error' variant

Field note

Apple Silicon developers: default release downloads are often aarch64 — check what your deploy target runs before scp'ing. file(1) also catches corrupt downloads ('data' instead of 'ELF') — re-fetch and checksum in that case.

Common questions

Why does my Docker container fail with exec format error at startup?

The image's binaries don't match the host (or the --platform you forced): an arm64 image on amd64, or vice versa. Match platforms explicitly in build/run, or build multi-arch manifests.

Can I run x86 binaries on ARM?

Only via emulation (qemu binfmt + docker --platform), with a real performance cost — and it fails for some syscalls. Prefer native builds per arch in CI (docker buildx --platform linux/amd64,linux/arm64).

Ship it right the first time

Our most-documented failures, packaged as ready-to-ship starter kits: Docker, Kubernetes, and Terraform.

Browse the template store →

One-time. Yours to modify. Instant download from the NinjaOps template store.

Get new fixes by email

One short email when new fixes and production templates drop. No spam, unsubscribe anytime.

Partner pick — sponsored

Vultr — our lab-environment pick for this stack

Spin up a cloud server in 60 seconds and reproduce this fix yourself — pay by the hour.

Get Vultr →
Also vetted

Sentry — Free tier: see the exact line of code that broke, before users report it.

Get Sentry →

We earn a commission if you buy through our links — it never costs you extra. More vetted tools on our picks hub · comparing clouds? DigitalOcean vs Vultr and vs AWS · full deals: DigitalOcean · Vultr · NordLayer · Semrush