Skip to content

Documentation

Troubleshooting Guide — Fix Localhost 5173, Port Collisions, Setup, & Errors

Diagnose and fix SveltyCMS issues: localhost:5173 /admin and /login access, port collisions (lsof -i :5173, kill process), setup wizard, database errors, and auth.

11/6/2026
7 min read Edit on GitHub

Solutions for common installation, configuration, local dev, port collisions, and operational issues.


🚀 Local Access & Dev Server Port Collisions (localhost:5173 / localhost:3000)

Accessing Local Admin (http://localhost:5173/admin, /login, or /dashboard)

Symptoms: Opening localhost:5173/admin redirects to /setup, /login, or throws a 404/CSRF error.

Causes & Fixes:

  1. First-Run Setup Redirection:
    • If config/private.ts has not been generated yet, SveltyCMS runs in unconfigured mode. Any request to /admin or /login will fail-closed and automatically redirect to http://localhost:5173/setup.
    • Complete the 5-step wizard at /setup to generate the system keys and initial admin user.
  2. Post-Setup Login Route:
    • Once setup is completed, /login is the primary authentication route.
    • The admin dashboard is mounted at /dashboard (and collection routes /(app)), rather than a standalone static /admin path. Typing /admin automatically routes to /dashboard when authenticated, or /login when unauthenticated.
  3. CSRF / Origin Mismatch on Preview:
    • When running on non-standard ports (e.g., http://localhost:4173), ensure the request origin is listed in csrf.trustedOrigins inside vite.config.ts. SveltyCMS automatically trusts the full loopback range (http://localhost:4173–4773).

Port Collisions & Killing Hanging Processes (5173 / 3000)

Symptoms: Error: listen EADDRINUSE: address already in use :::5173 or Vite automatically starts on 5174 / 5175.

Step 1: Identify the process occupying the port

  • macOS / Linux:

    # Check port 5173
    lsof -i :5173
    
    # Check port 3000
    lsof -i :3000
  • Windows (PowerShell / Command Prompt):

    # Find PID listening on 5173
    netstat -ano | findstr :5173
    
    # Find PID listening on 3000
    netstat -ano | findstr :3000

Step 2: Terminate the blocking process

  • macOS / Linux:

    # Terminate by Process ID (PID)
    kill -9 <PID>
    
    # Or kill by port directly
    npx kill-port 5173
  • Windows:

    # Command Prompt / PowerShell
    taskkill /PID <PID> /F
    
    # PowerShell native
    Stop-Process -Id <PID> -Force

Step 3: Test connection using curl

# Verify the dev server responds with HTTP 200 / 303
curl -i http://localhost:5173/

🛠️ Setup & Installation

“Initializing System” hangs

Symptoms: Splash screen stays on “Initializing System” indefinitely, or MIME type error (text/html instead of JavaScript).

Fix:

  1. Delete config/private.ts if corrupted or empty, then restart bun run dev
  2. Clear Vite cache:
    rm -rf node_modules/.vite
    bun run dev
  3. Verify hooks.server.ts isn’t crashing before handleSystemState

Database connection failed

Symptoms: Check your credentials or ECONNREFUSED.

Fix:

Database Action
MongoDB Verify cluster hostname, whitelist your IP in Atlas
PostgreSQL / MariaDB Database must exist before running wizard
SQLite Ensure the directory for .db file has write permissions

Mechanics: src/databases/db.ts probes the connection. Use bun run check for isolated testing (MongoDB-specific diagnostics script not currently available).


Windows bun install corruption

Symptoms: bun install v1.3.11+ on Windows may write null bytes into package.json files or leave directories empty. Results in ParserError for @sveltejs/kit or esbuild.

Fix: Use npm install instead.

npm install    # Works reliably on Windows
bun run dev    # Bun's runtime works fine after npm install

This only affects the Bun installer on Windows. Bun’s runtime and bun run commands work normally.

Docker container won’t start or stays unhealthy

Symptoms: Container exits immediately, docker run never reports healthy, or the build fails.

Fix:

  1. SveltyCMS has no published image — build it from the multi-stage Dockerfile in Production deployment:
    docker build -t sveltycms .
  2. Check startup logs:
    docker logs <container>
    On first start the Setup Wizard runs at http://localhost:4173 — complete it once before the healthcheck goes green.
  3. Persist state: mount /app/config (-v svelty_data:/app/config) so the SQLite database and config/private.ts survive restarts.
  4. The image defaults to SQLite. For another engine, pass -e DB_TYPE=postgresql (or mariadb / mongodb) plus the matching DB_* variables, and make the database reachable from the container.

🔐 Authentication & Sessions

“Unauthorized” or session expired immediately

Symptoms: Logged out immediately after login, 401 on all API calls.

Fix:

  1. Clear browser cookies for your domain and retry
  2. If you manually edited config/private.ts and changed JWT_SECRET_KEY, all sessions are invalidated — log in again
  3. Ensure server system time is synchronized — divergent times cause JWT expiration

Account locked (HTTP 423)

Symptoms: Account locked after multiple failed login attempts.

Fix: Wait 15 minutes for automatic unlock. This is a security feature — 5 failed attempts trigger a temporary lockout.


🧩 Widgets & Collections

New widget doesn’t appear in Dashboard

Fix: Use the “Sync Widgets” button in ⚙️ Config → System Settings → Widgets. The scanner runs on HMR, but the database registry needs a manual trigger for new custom widgets.

Collection Builder field not saving

Fix: Ensure db_fieldName values are unique within a collection — duplicate names are rejected. Check the browser console for validation errors.


🔁 Dev Server & HMR

“Vite module runner has been closed” repeats while the scanner recompiles

Symptoms: the dev terminal repeats some of these in a burst:

[Loader] Failed to load pages.js {"error":"Vite module runner has been closed."}
[Scanner] Broken compiled schema, triggering recompilation {"path":"...\\.compiledCollections\\pages.js"}
[Scanner] Walk failed ... ENOENT ... pages.js
Failed to warm cache ... Vite module runner has been closed.

Cause: Vite closes the SSR module runner during HMR/restart. A schema scan that lands in that window used to treat the failure as a broken compiled file, delete it and touch the source (utimes) to force a recompile. The recompile finished while the next runner was still closing, so the cycle repeated.

Fix: current code classifies module runner has been closed (and The server is being restarted) as transient: the compiled file is kept, the source is not touched, and the scanner retries on the next pass; cache warming skips the same window, stops its own timer on the first closed-runner detection, and hands the singleton to the next HMR evaluation through globalThis (the predecessor’s timers are cleared before the new instance is installed). A dev server that was already running before the fix still holds the old module graph — restart it once (Ctrl+C → bun run dev) to load the fix. After that, HMR re-evaluation disposes the predecessor without a restart. If a restart does not clear a stale dependency error, remove the Vite cache: rm -rf node_modules/.vite && bun run dev.

Compiled schema is recompiled but the collection still disappears

Fix: check whether the scan reports Broken compiled schema (real file problem) or only Deferring … dev module runner restarting (transient). Only the first should trigger a source edit. If a collection is missing after a crash, let one request finish after the runner is back — the scanner rescans on demand — or run the Sync action in /config/sync.


📈 Performance

“JavaScript heap out of memory”

Symptoms: Build fails on large media libraries or complex collections.

Fix: Increase Node.js memory limit:

export NODE_OPTIONS="--max-old-space-size=4096"
bun run build

Slow API responses in production

Fix:

  1. Verify Redis is configured and running (check config/private.ts)
  2. Check MEDIA_STORAGE_TYPE — local storage is faster than cloud for small deployments
  3. Run benchmarks to identify bottlenecks:
    bun test tests/benchmarks/database-performance.test.ts

🆘 Still Stuck?

  1. View logs: Check the terminal where bun run dev runs
  2. Run diagnostics:
    bun run check
    bun run test:unit
  3. Community: GitHub Discussions · Discord

Related

troubleshootingdebuggingsupportfaqlocalhost-5173lsof-5173kill-processnetstatlocalhost-adminlocalhost-loginvite-dev-server
Was this page helpful?