Skip to content
Latchkey

Prisma "Unable to require libquery_engine" (libssl/musl on Alpine) in CI

On Alpine the Prisma Query Engine is the linux-musl build and it dynamically links OpenSSL. Alpine ships without libssl by default, so the engine cannot load and the client fails to initialize.

What this error means

On an Alpine (musl) runner or image the client throws "Unable to require(.../libquery_engine-linux-musl.so.node)" mentioning libssl.so, or "Error loading shared library libssl.so.1.1: No such file or directory".

Prisma
PrismaClientInitializationError: Unable to require(`/app/node_modules/.prisma/client/libquery_engine-linux-musl.so.node`).
Error loading shared library libssl.so.1.1: No such file or directory (needed by /app/node_modules/.prisma/client/libquery_engine-linux-musl.so.node)

Common causes

Alpine has no OpenSSL installed

The musl engine links libssl at load time, but a minimal Alpine image does not include openssl, so the shared library is missing.

The musl binaryTarget was not generated

If the client was generated without linux-musl in binaryTargets, the Alpine-compatible engine is absent entirely.

How to fix it

Install OpenSSL and generate for musl

  1. Install openssl (and libc6-compat where needed) in the Alpine image.
  2. Add linux-musl-openssl-3.0.x (or linux-musl) to binaryTargets.
  3. Run prisma generate so the musl engine is produced.
Dockerfile
RUN apk add --no-cache openssl
# schema.prisma:
# binaryTargets = ["native", "linux-musl-openssl-3.0.x"]

Use a glibc base image instead

Switching to a Debian slim image avoids the musl/openssl mismatch, using the debian-openssl engine.

Dockerfile
FROM node:20-slim
RUN apt-get update && apt-get install -y openssl

How to prevent it

  • Install openssl in Alpine images that run Prisma.
  • Include the musl binaryTarget when you deploy or test on Alpine.
  • Prefer a glibc base image if you do not need Alpine.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →