Go raises the cannot execute binary file: exec format error “when a binary file for a specific processor architecture is run on a different architecture”, e.g., an x86 executable is run on an ARM CPU.
Here is the step-by-step guide to fix the “cannot execute binary file: exec format” error:
- Verify system architecture
- Download the correct binary
- Build from the source
- Install the Go compiler and build the binary
- Make the binary executable
- Run the binary
Step 1: Verify system architecture
Check your system’s architecture (32-bit or 64-bit) and make sure you have the correct binary for your system. You can run uname -m in the terminal to check your system’s architecture.
Step 2: Download the correct binary
If you installed the wrong binary, download the correct version for your system from the official source or build it yourself.
Step 3: Build from the source
If you have the source code for the Go program, you can try building it yourself. First, ensure you have the Go compiler installed on your system. Then, you can download it from the official Go website: https://go.dev/dl/.
Step 4: Install the Go compiler and build the binary
Once you have the Go compiler installed, navigate to the directory containing the source code and run the following command to build the binary:
go build
This will create an executable binary in the current directory. Make sure the binary is compatible with your system’s architecture.
Step 5: Make the binary executable
Ensure that the binary file has executable permissions. You can use the chmod command to add executable permissions.
chmod +x your_binary_file
Step 6: Run the binary
Now you can run the binary without the “Exec format error”. Execute the binary with ./your_binary_file.
If you still encounter the error after following these steps, the binary file might be corrupt, or an issue with your system’s environment.
In this case, you might need assistance from the software developers or your system administrator.
That’s it.

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.