[Bug]: API service crash due to DB table not found
Preliminary Checks
- [x] I have searched existing issues for similar problems
- [x] I have read the troubleshooting documentation
- [x] I am using a supported version of HeadlessX
HeadlessX Version
v2.0.4
Installation Method
Docker
Affected App/Package
apps/api (Backend API)
Environment
Nixos on nixpkgs-unstable, docker 29.2.1
Bug Description
Hello, I'm trying to run this on NixOS using Docker but the API service fails, apparently due to a DB table not found.
Maybe I misunderstood the installation instructions but as far as I can see I don't need to run the pnpm commands for the db and camoufox, right? That would defeat the purpose of running the services in a container.
The project looks promising, thanks!
Expected Behavior
The API services runs fine
Actual Behavior
The API service crashes
Steps to Reproduce
cd infra/docker && docker compose --profile all up -d
Error Logs
headlessx-api |
headlessx-api | > [email protected] start /app/apps/api
headlessx-api | > dotenv -e ../../.env -- tsx src/server_entry.ts
headlessx-api |
headlessx-api | [[email protected]] injecting env (0) from ../../.env -- tip: ⚙️ write to custom object with { processEnv: myObject }
headlessx-api | ⚠️ Could not load .env from /app/.env
headlessx-api | ❌ Classification model missing: /app/apps/api/models/recaptcha_classification_57k.onnx
headlessx-api | ❌ Detection model missing: /app/apps/api/models/yolo26x.onnx
headlessx-api | ❌ Failed to start server: PrismaClientKnownRequestError:
headlessx-api | Invalid `prisma.profile.findMany()` invocation:
headlessx-api |
headlessx-api |
headlessx-api | The table `public.Profile` does not exist in the current database.
headlessx-api | at zr.handleRequestError (/app/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_njfa7jft5cccarmfgbncvg4xwi/node_modules/@prisma/client/src/runtime/RequestHandler.ts:237:13)
headlessx-api | at zr.handleAndLogRequestError (/app/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_njfa7jft5cccarmfgbncvg4xwi/node_modules/@prisma/client/src/runtime/RequestHandler.ts:183:12)
headlessx-api | at zr.request (/app/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_njfa7jft5cccarmfgbncvg4xwi/node_modules/@prisma/client/src/runtime/RequestHandler.ts:152:12)
headlessx-api | at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
headlessx-api | at async a (/app/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_njfa7jft5cccarmfgbncvg4xwi/node_modules/@prisma/client/src/runtime/getPrismaClient.ts:808:24)
headlessx-api | at async ProfileService.ensureDefaultProfile (/app/apps/api/src/services/ProfileService.ts:506:26)
headlessx-api | at async startServer (/app/apps/api/src/server_entry.ts:16:9) {
headlessx-api | code: 'P2021',
headlessx-api | meta: {
headlessx-api | modelName: 'Profile',
headlessx-api | driverAdapterError: DriverAdapterError: TableDoesNotExist
headlessx-api | at PrismaPgAdapter.onError (file:///app/node_modules/.pnpm/@[email protected]/node_modules/@prisma/adapter-pg/dist/index.mjs:651:11)
headlessx-api | at PrismaPgAdapter.performIO (file:///app/node_modules/.pnpm/@[email protected]/node_modules/@prisma/adapter-pg/dist/index.mjs:646:12)
headlessx-api | at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
headlessx-api | at async PrismaPgAdapter.queryRaw (file:///app/node_modules/.pnpm/@[email protected]/node_modules/@prisma/adapter-pg/dist/index.mjs:566:30)
headlessx-api | at async e.interpretNode (/app/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_njfa7jft5cccarmfgbncvg4xwi/node_modules/@prisma/client-engine-runtime/src/interpreter/query-interpreter.ts:182:26)
headlessx-api | at async e.interpretNode (/app/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_njfa7jft5cccarmfgbncvg4xwi/node_modules/@prisma/client-engine-runtime/src/interpreter/query-interpreter.ts:268:41)
headlessx-api | at async e.run (/app/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_njfa7jft5cccarmfgbncvg4xwi/node_modules/@prisma/client-engine-runtime/src/interpreter/query-interpreter.ts:93:23)
headlessx-api | at async e.execute (/app/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_njfa7jft5cccarmfgbncvg4xwi/node_modules/@prisma/client/src/runtime/core/engines/client/LocalExecutor.ts:81:12)
headlessx-api | at async qt.request (/app/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_njfa7jft5cccarmfgbncvg4xwi/node_modules/@prisma/client/src/runtime/core/engines/client/ClientEngine.ts:492:22)
headlessx-api | at async Object.singleLoader (/app/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_njfa7jft5cccarmfgbncvg4xwi/node_modules/@prisma/client/src/runtime/RequestHandler.ts:112:26) {
headlessx-api | cause: [Object]
headlessx-api | }
headlessx-api | },
headlessx-api | clientVersion: '7.4.1'
headlessx-api | }
headlessx-api | ELIFECYCLE Command failed with exit code 1.
Configuration
I'm pretty much using the defaults in the `infra/docker/.env` file:
# ==============================================
# 🚀 HEADLESSX V2.0 - CAMOUFOX
# ==============================================
# ------------------------------
# 1. DATABASE (Supabase PostgreSQL)
# ------------------------------
# DATABASE_URL="postgresql://postgres.xxxxx:[email protected]:5432/postgres"
# ------------------------------
# 2. SERVER
# ------------------------------
PORT=8000
HOST=0.0.0.0
NODE_ENV=development
# ------------------------------
# 2A. SECURITY (REQUIRED)
# ------------------------------
# Used by the Next.js dashboard server to authenticate against the API.
DASHBOARD_INTERNAL_API_KEY=<redacted>
# Used to encrypt stored proxy and profile passwords at rest.
CREDENTIAL_ENCRYPTION_KEY=<redacted>
# ------------------------------
# 3. PROFILE STORAGE
# ------------------------------
PROFILES_DIR=./data/profiles
# ------------------------------
# 4. LOGGING
# ------------------------------
LOG_LEVEL=info
LOG_DIR=./logs
# ⚙️ Browser & Anti-Detection settings are managed via:
# Frontend Settings Page → Saved in SystemSettings DB table
#
# Settings managed in UI:
# - BROWSER_HEADLESS
# - BROWSER_TIMEOUT
# - MAX_CONCURRENCY
# - CAMOUFOX_OS, CAMOUFOX_HUMANIZE, CAMOUFOX_GEOIP, etc.
# - STEALTH_MODE
# - FINGERPRINT_PROFILE
# - PROFILE_ROTATION_ENABLED/INTERVAL
# - PROXY settings
# ------------------------------
# 5. FRONTEND (Next.js)
# ------------------------------
# Frontend dashboard port (used by apps/web dev/start scripts)
WEB_PORT=3000
NEXT_PUBLIC_API_URL=http://localhost:8000
# CORS: Add your frontend URL for custom deployments
# (automatically added to CORS allowed origins)
FRONTEND_URL=http://localhost:3000
Severity
Critical (application crashes, security vulnerability)
Browser Context
None
Additional Context
No response
Contribution
- [x] I am willing to help fix this bug
- [x] I can provide additional testing
- [x] I can help with documentation updates
Hello @Alfablos ! I faced the same problem as you. As a temporary solution, I manually applied migration scripts (apps/api/prisma/migrations/20260129070536_init_v2_schema/migration.sql) to the database deployed in docker. I applied this script from this repository manually and headlessx-api started! I hope this information will be useful.
Thanks for the hint. I wanted to modify the migration adding some "IF NOT EXISTS" and add psql in the container to replace the command with the psql command to prepare the db && current cmd. However I also noticed that you can't use the playground without installing (API service) the following packages:
- libgtk-3-0
- libx11-xcb1
But that's for a different issue.
fixed, try v2.1.0