cannot execute binary file: Exec format error — how to fix
bash: ./app: cannot execute binary file: Exec format error
Quick fix: Compare file ./app with uname -m. Download the build for your architecture (x86_64/amd64 vs aarch64/arm64), or rebuild from source. Scripts need a shebang line like #!/bin/bash.
What it means
The kernel looked at the file's header and couldn't run it on this machine.
Check both sides:
uname -m # x86_64, aarch64, armv7l ...
file ./app
Examples of file output:
ELF 64-bit LSB executable, x86-64→ needsx86_64ELF 64-bit LSB executable, ARM aarch64→ needsaarch64Mach-O 64-bit executable arm64→ a macOS binary; won't run on Linux at allPE32+ executable (console) x86-64, for MS Windows→ a Windows.exe
Fix 1: download the right build
Release pages usually offer linux-amd64 / linux-x86_64 and linux-arm64 / linux-aarch64 variants. Raspberry Pi OS 32-bit needs armv7/armhf builds; 64-bit Pi OS needs arm64.
Fix 2: build from source
go build ./... # Go builds for the current machine
cargo build --release # Rust
Cross-compiling for another target: GOOS=linux GOARCH=arm64 go build, or cargo build --target aarch64-unknown-linux-gnu.
Fix 3: run under emulation
Install QEMU user-mode emulation (slow, but works for occasional use):
sudo apt install qemu-user-static binfmt-support
./app
Fix 4: it's not a binary
- Running a text script with
./script.shand no shebang can fail this way under some shells; add#!/bin/bashas the first line. - A corrupted or incomplete download (an HTML error page saved as
app) gives the same error. Check withfileandhead -c 200 app. bash ./appon a binary givescannot execute binary filetoo — run it directly with./app.
Last updated 2026-10-29.