[V3] Error 500 when refreshing parsed content page in production using Docker
Environment
- Operating System: Windows_NT
- Node Version: v20.16.0
- Nuxt Version: 3.15.2
- CLI Version: 3.20.0
- Nitro Version: 2.10.4
- Package Manager: [email protected]
- Builder: -
- User Config: compatibilityDate, devtools, modules, vite, typescript
- Runtime Modules: @nuxt/[email protected]
- Build Modules:
Reproduction
Describe the bug
I'm encountering an issue when deploying a Nuxt Content project in a production environment using Docker. Refreshing a page that displays parsed content (not navigating via routes) results in a 500 error. The error message is as follows:
[POST] "/api/content/docs/query?v=TognxvETDU": 500
After checking the server logs, I found this error:
Failed to execute SQL DROP TABLE IF EXISTS _content_docs;: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error...
Upon further investigation, I entered the Docker container and noticed that the contents.sqlite file is not generated in the server directory.
Strangely, navigating to the content page via route transitions works fine. The issue only occurs when refreshing a parsed content page directly.

Finally, this is my Dockerfile file
FROM node:20-alpine3.20
RUN mkdir -p /home
WORKDIR /home
ENV HOST 0.0.0.0
COPY ./.output /home
EXPOSE 3000/tcp
CMD ["node", "server/index.mjs"]
Could you please provide guidance on resolving this issue? Let me know if additional information is needed.
Thank you!
Additional context
No response
Logs
Listening on http://0.0.0.0:3000
Failed to execute SQL DROP TABLE IF EXISTS _content_docs;: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL CREATE TABLE IF NOT EXISTS _content_docs (id TEXT PRIMARY KEY, "title" VARCHAR, "body" TEXT, "date" VARCHAR, "description" VARCHAR, "extension" VARCHAR, "image" VARCHAR, "meta" TEXT, "navigation" TEXT DEFAULT true, "path" VARCHAR, "seo" TEXT DEFAULT '{}', "stem" VARCHAR, "tags" TEXT, "updated" VARCHAR);: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL INSERT INTO _content_docs VALUES ('docs/docs/1.index.md', 'demo1', '{"type":"minimal","value":[["h2",{"id":"title"},"title"],["p",{},"demo1"]],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"title","depth":2,"text":"title"}]}}', '2025-01-14 16:00:00', '', 'md', NULL, '{}', 'true', '/docs', '{"title":"demo1","description":""}', 'docs/1.index', '["Spring","AI"]', NULL);: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL INSERT INTO _content_docs VALUES ('docs/docs/2.index2.md', 'demo2', '{"type":"minimal","value":[["h2",{"id":"title"},"title"],["p",{},"demo2"]],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"title","depth":2,"text":"title"}]}}', '2025-01-14 16:00:00', '', 'md', NULL, '{}', 'true', '/docs/index2', '{"title":"demo2","description":""}', 'docs/2.index2', NULL, NULL);: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL CREATE TABLE IF NOT EXISTS _content_info (id TEXT PRIMARY KEY, "version" VARCHAR);: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL DELETE FROM _content_info WHERE id = 'checksum_docs';: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL INSERT INTO _content_info VALUES ('checksum_docs', 'TognxvETDU');: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Since there is a native dependency in the project, you need to build your project inside your docker file. Building the project outside will install incompatible binary which cannot be execute in the alpine architecture.
Checkout this docker file https://github.com/Phu1237/nuxt-content-docker/blob/master/Dockerfile
I have the same error without Docker - this message is displayed only in production
[POST] "/api/content/tags/query?v=C5HC8qALLi": 500
The tags collection is the first one to get queried on the home page:
<script setup>
const tags = await queryCollection('tags').all()
const questions = await queryCollection('questions').all()
</script>
Am I doing something wrong? I feel like this worked before, but I can't remember if it was before upgrading to v3 or not...
edit: ✅ solved it with
const { data: tags } = await useAsyncData('tags', () => queryCollection('tags').all())
const { data: questions } = await useAsyncData('questions', () => queryCollection('questions').all())
@muffincode I solved this issue by modifying the database for PostgreSQL. You can also use SQLite, but it requires packaging on the server (which I wasn’t successful with).