Home › Linux & shell

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:

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

Last updated 2026-10-29.