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.
On this page
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:
- First-Run Setup Redirection:
- If
config/private.tshas not been generated yet, SveltyCMS runs in unconfigured mode. Any request to/adminor/loginwill fail-closed and automatically redirect tohttp://localhost:5173/setup. - Complete the 5-step wizard at
/setupto generate the system keys and initial admin user.
- If
- Post-Setup Login Route:
- Once setup is completed,
/loginis the primary authentication route. - The admin dashboard is mounted at
/dashboard(and collection routes/(app)), rather than a standalone static/adminpath. Typing/adminautomatically routes to/dashboardwhen authenticated, or/loginwhen unauthenticated.
- Once setup is completed,
- CSRF / Origin Mismatch on Preview:
- When running on non-standard ports (e.g.,
http://localhost:4173), ensure the request origin is listed incsrf.trustedOriginsinsidevite.config.ts. SveltyCMS automatically trusts the full loopback range (http://localhost:4173–4773).
- When running on non-standard ports (e.g.,
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:
- Delete
config/private.tsif corrupted or empty, then restartbun run dev - Clear Vite cache:
rm -rf node_modules/.vite bun run dev - Verify
hooks.server.tsisn’t crashing beforehandleSystemState
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.tsprobes the connection. Usebun run checkfor 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 runcommands work normally.
Docker container won’t start or stays unhealthy
Symptoms: Container exits immediately, docker run never reports healthy, or the build fails.
Fix:
- SveltyCMS has no published image — build it from the multi-stage
Dockerfilein Production deployment:docker build -t sveltycms . - Check startup logs:
On first start the Setup Wizard runs atdocker logs <container>http://localhost:4173— complete it once before the healthcheck goes green. - Persist state: mount
/app/config(-v svelty_data:/app/config) so the SQLite database andconfig/private.tssurvive restarts. - The image defaults to SQLite. For another engine, pass
-e DB_TYPE=postgresql(ormariadb/mongodb) plus the matchingDB_*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:
- Clear browser cookies for your domain and retry
- If you manually edited
config/private.tsand changedJWT_SECRET_KEY, all sessions are invalidated — log in again - 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:
- Verify Redis is configured and running (check
config/private.ts) - Check
MEDIA_STORAGE_TYPE— local storage is faster than cloud for small deployments - Run benchmarks to identify bottlenecks:
bun test tests/benchmarks/database-performance.test.ts
🆘 Still Stuck?
- View logs: Check the terminal where
bun run devruns - Run diagnostics:
bun run check bun run test:unit - Community: GitHub Discussions · Discord