Skip to content

Troubleshooting

Terminal window
# Clean and rebuild
yarn clean
yarn typecheck
yarn build

If typecheck reports errors, fix the TypeScript issues before building.

Terminal window
# Rebuild Tailwind
yarn build:tailwind
# Check for CSS syntax errors in src/assets/css/app.css
Terminal window
# Regenerate Prisma client (SQLite)
yarn db:generate
# Regenerate Prisma client (PostgreSQL)
yarn db:generate:pg
# Push schema changes
yarn db:push

Symptom: MongooseServerSelectionError: connect ECONNREFUSED

  • Verify MongoDB is running: sudo systemctl status mongod
  • Check the URI: mongosh "STORAGE_MONGODB_URI"
  • Verify network access if using a remote database
  • Check authentication credentials

Symptom: MongooseError: Operation timed out

  • Check MongoDB logs: sudo journalctl -u mongod
  • Verify available disk space: df -h
  • Check memory usage: free -m

Symptom: Error: connect ECONNREFUSED

  • Verify PostgreSQL is running: sudo systemctl status postgresql
  • Check connection URL format: postgresql://user:password@host:port/database
  • Verify pg_hba.conf allows your connection method
  • Test connection: psql "STORAGE_POSTGRESQL_URL"

Symptom: Error: relation does not exist

  • Run migrations: yarn db:migrate:deploy
  • Or push schema: yarn db:push

Symptom: SQLITE_BUSY: database is locked

  • Ensure PM2_INSTANCES=1 — SQLite does not support multiple writers
  • Check for zombie processes: ps aux | grep parako
  • Kill stuck processes and restart

Symptom: SQLITE_CANTOPEN: unable to open database file

  • Verify the database path exists: ls -la data/
  • Check directory permissions
  • Ensure the STORAGE_SQLITE_PATH directory is writable

Symptom: Error: No keys found or OIDC provider fails to start

Terminal window
yarn keys generate

JWKS keys must be generated before the first startup.

Symptom: invalid_client error during token exchange

  • Verify client exists: yarn client list
  • Check client_id and client_secret match
  • Verify token_endpoint_auth_method matches your request (e.g., client_secret_basic requires HTTP Basic auth)
  • Check if the client is active (not deactivated)

Symptom: redirect_uri_mismatch error

  • The redirect URI in the authorization request must exactly match one registered with the client
  • Check for trailing slashes, http vs https, port numbers
  • View client redirect URIs: open /admin → OIDC Clients, or cat parako-rp.jsonc

Symptom: invalid_scope error

  • Verify the requested scopes are registered with the client
  • Check the client’s allowed scopes: open /admin → OIDC Clients, or cat parako-rp.jsonc
  • Verify the user account exists and is not locked
  • Check if the password has expired (max_age_days policy)
  • Check if password breach detection is blocking the password
  • TOTP: Verify the user’s device clock is synchronized (TOTP is time-based)
  • Email OTP: Check SMTP configuration and email delivery logs
  • SMS: Verify Twilio credentials and phone number format
  • WebAuthn: Verify rp_id matches your domain in production
  • Verify provider credentials (client_id, client_secret) are correct
  • Check that the redirect URI matches exactly: https://your-domain/auth/social/{provider}/callback
  • Verify the provider app is in production mode (not sandbox/test mode)
  • Check if the provider’s OAuth consent screen is configured
  • Check session store configuration (MongoDB or Redis)
  • Verify Redis is running if used for sessions: redis-cli ping
  • Check cookie settings — secure: true requires HTTPS
  • Verify sameSite cookie setting is compatible with your setup
  • Verify MULTI_TENANCY_ENABLED=true
  • Check MULTI_TENANCY_EXTRACTION_PRIORITY — session should be first
  • Verify the HMAC_SECRET is set for cross-tenant state signing
  • Check that tenant resolution is working: add debug logging
Terminal window
# All logs
pm2 logs
# Application logs only
pm2 logs parako-id
# Worker logs only
pm2 logs parako-id-worker
# Clear logs
pm2 flush

Symptom: SQLITE_BUSY errors, data corruption

You must set PM2_INSTANCES=1 when using SQLite. The application enforces this at startup — if you set more than 1 instance with SQLite, the app refuses to start.

For multi-process deployments, switch to PostgreSQL or MongoDB.

Symptom: Process restarts frequently, max_memory_restart triggered

  • Increase PM2_MAX_MEMORY (default: 1G)
  • Check for memory leaks: pm2 monit
  • Consider adding more RAM or reducing PM2_INSTANCES
Terminal window
# Check PM2 status
pm2 list
# View startup errors
pm2 logs parako-id --err --lines 50
# Delete and restart
pm2 delete ecosystem.config.cjs
yarn start
  • Ensure the service user has read/write access to the application directory
  • Check file ownership: ls -la /opt/parako/
  • Verify the .env file is readable by the service user
Terminal window
# Application logs
journalctl -u parako-id -f
# Worker logs
journalctl -u parako-id-worker -f
# Recent errors
journalctl -u parako-id --since "1 hour ago" -p err
Terminal window
# Check status
yarn systemd status
# Validate unit file
systemd-analyze verify /etc/systemd/system/parako-id.service
# Reload after editing unit files
sudo systemctl daemon-reload
sudo systemctl restart parako-id
  • Check MULTI_TENANCY_EXTRACTION_PRIORITY order
  • Verify the tenant exists in the database
  • For header extraction, confirm the x-tenant-id header is being sent
  • For subdomain extraction, verify DNS and nginx wildcard configuration

Multi-tenancy is not supported with SQLite. Switch to MongoDB or PostgreSQL.

Symptom: Slow tenant switching, memory growth

  • Increase MULTI_TENANCY_PROVIDER_POOL_MAX_SIZE (default: 50)
  • Decrease MULTI_TENANCY_PROVIDER_POOL_IDLE_TTL_MS to evict idle providers faster
  • Monitor memory usage with pm2 monit or Prometheus metrics
  • Enable Redis for OIDC storage (OIDC_STORAGE_ADAPTER=redis) for faster token lookups
  • Increase PM2 instances for multi-core utilization (PostgreSQL/MongoDB only)
  • Check database query performance and add indexes if needed
  • Enable response caching in nginx
  • Reduce PM2_INSTANCES count
  • Lower PM2_MAX_MEMORY to trigger restarts earlier
  • In multi-tenant mode, reduce provider pool size
  • Check for memory leaks in custom view templates
Terminal window
# MongoDB: check slow queries
mongosh parako --eval "db.setProfilingLevel(1, {slowms: 100})"
mongosh parako --eval "db.system.profile.find().sort({ts: -1}).limit(5)"
# PostgreSQL: analyze query performance
psql -d parako -c "SELECT * FROM pg_stat_user_tables ORDER BY seq_tup_read DESC;"
psql -d parako -c "VACUUM ANALYZE;"