# Deploy failed when running balena deploy

**URL:** <https://forums.balena.io/t/deploy-failed-when-running-balena-deploy/5486>\
**Category:** openBalena\
**Created:** [February 28, 2019, 12:00pm UTC](https://forums.balena.io/t/deploy-failed-when-running-balena-deploy/5486 "2019-02-28T12:00:46Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![pdcastro](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pdcastro/32/1264_2.png) [@pdcastro](https://forums.balena.io/u/pdcastro)\
**Post date:** [January 23, 2020, 9:00pm UTC](https://forums.balena.io/t/deploy-failed-when-running-balena-deploy/5486/10 "2020-01-23T21:00:55Z")

</div>

@Ciantic, they key error is probably:

```nohighlight
[Build] main /bin/sh: Invalid ELF image for this architecture

```

Which usually indicates a CPU architecture mismatch, such as Intel vs ARM, 32 bit vs 64 bit. It is happening at Dockerfile step 5/13, `"npm install --unsafe-perm --production"`.

Given the following output:

```nohighlight
[Info] Building for aarch64/raspberrypi4-64
[Info] Installing qemu for aarch64 emulation...
[Debug] Resolving services with [raspberrypi4-64|aarch64]

```

I gather that you project is for the RPi 4, 64 bits. The base image is however for the RPi 3, 32 bits:

```nohighlight
[Build] main Step 1/13 : FROM balenalib/raspberrypi3-node:8-build AS base

```

I don’t know if this image mismatch is necessarily a problem – I actually seem to remember that the RPi3 image works fine on the RPi4. However, it might be worth trying an RPi 4 base image, `balenalib/raspberrypi4-64-node`.

Also: `balena deploy`, as used, is building the image using your laptop (dev machine) Docker installation. To narrow down the issue, try also building without emulation on balenaCloud builders (we have ARM servers) with `balena push`, and/or building on a real RPi4 device on your desk. To test the latter, flash a [development image](https://www.balena.io/docs/reference/OS/overview/2.x/#development-vs-production-images) and place the device in [local mode](https://www.balena.io/docs/learn/develop/local-mode/), then run something like:

```nohighlight
balena deploy myApp --logs --source . --dockerPort 2375 --dockerHost 192.168.1.2

```

replacing `192.168.1.2` with your device’s IP address.

If building without emulation works, the problem may be that [QEMU](https://www.qemu.org/) is simply not up to the task; it is known to fail on some compilation tasks or other tasks, which `npm install` may be triggering. Try also running some other binary executables (other than `npm`) to rule this out – starting with something like `/bin/sh -c 'echo hello world'`.

---

_[View the full topic](https://forums.balena.io/t/deploy-failed-when-running-balena-deploy/5486)._
