All documents

MERIDIAN · DOC 21 / 25

Troubleshooting

WebSocket, host resolution, cookies, database, deploy, SSL — symptom to fix maps.

Symptom → cause → where to look → fix. Start with the logs — pm2 logs meridian — and work down the checklist in the affected lane.


WebSockets / realtime

SymptomLikely causeFix
WS handshake 400Upgrade/Connection headers not mappedconfirm map $http_upgrade $connection_upgrade block + /socket.io/ location exists in /etc/nginx/sites-enabled/yourplatform.confsudo nginx -t && sudo systemctl reload nginx
502 Bad Gatewayapp down or still bootingpm2 status, pm2 logs meridian, then curl -i http://127.0.0.1:3000/api/health on the VPS
Reconnect loop on every pageCloudflare proxy/timeout killing idle sockets, or cookie-session confusionbypass-cache for /socket.io/*, raise Cloudflare WS timeouts (default ~100s idle), confirm the socket subscribe ack appears in logs (socket joined tracking room)
"origin not allowed" at handshakeOrigin header not on the allow listrequests should come from the same tenant host; production domain must equal NEXT_PUBLIC_PLATFORM_DOMAIN
Status stuck while DB changedbroadcast server down mid-boot, or room misjoinresync happens automatically on next poll-less reconnect; verify /api/ready; check pm2 logs meridian for package status changed
ECONNREFUSED on :3000 from NginxPM2 process deadpm2 restart meridian; if crash-looping: pm2 logs meridian --err --lines 100

Tenant subdomain / host resolution

SymptomCauseFix
Every subdomain shows developer portalhost matches a preview suffix platform listclear PLATFORM_HOST_SUFFIXES in production .env (it is empty in production)
Tenant site shows "Website Not Found"slug doesn't exist, or multi-label host, or DNS missing wildcardverify tenant slug in /admin/tenants; wildcard A record * in Cloudflare; Nginx server_name .nttrack.com
invalid tracking ID on a valid IDID pattern didn't match (length/charset)IDs are uppercase alnum+dash, 3–64 chars; recheck the copied value end-to-end
TENANT_NOT_FOUND from the tracking APIHost header lost/mangled upstreamNginx proxy_set_header Host $host must be present; Cloudflare passes Host by default

Cookies / authentication

SymptomCauseFix
Login succeeds, immediate logout/me = 401Cookie blocked (Secure on http), or wrong SameSite behaviorproduction REQUIRES https with Full (strict); never browse the app over http:// past Cloudflare
Logged out on every tab clashhost-only cookies are per-subdomain by DESIGNsign in per console host (admin.{domain} vs {slug}.{domain})
COOKIE_DOMAIN requestdoesn't exist intentionallysee docs/deployment.md §cookies

Database

| /api/ready = 503 NOT_READY | MongoDB unreachable | Atlas Network Access allows the VPS IP; credentials right; cluster paused (free tier)? pino log line mongodb connection failed | | Slow first query after deploy | cold pool/index | npx tsx scripts/ensure-indexes.ts once after release; harmless to re-run | | Backup questions | — | docs/backup-restore.md (procedure + drill) |

Build / deploy

| Build fails on types | code issue, not infra | npm run typecheck locally first; never next build --no-lint around it | | EACCES writing logs | /var/www/meridian/logs owned by root | sudo chown -R deploy:deploy /var/www/meridian/logs | | PM2 didn't come back after reboot | startup hook not installed | pm2 save then re-run the exact sudo line from pm2 startup systemd | | Deploy succeeded but site stale | browser cache/HTML cache or Cloudflare cache | hard-refresh; API+socket are already cache-bypassed per config |

SSL

| Cloudflare 526 (invalid origin cert) | origin lacks a valid cert under Full (strict) | run sudo certbot --nginx -d nttrack.com -d '*.nttrack.com' (or install the Cloudflare Origin Cert at the paths in the Nginx file), sudo nginx -t && sudo systemctl reload nginx | | Browser says insecure only on subdomain | wildcard certificate missing | certbot as above covers *; single-name certs won't — re-issue with *.nttrack.com included |

Recovery quick map

FailureDocument
VPS destroyeddocs/deployment.md (rebuild steps 1–8) + docs/backup-restore.md (Atlas survives)
Bad app releasedocs/deployment.md §9 rollback
Data corruptiondocs/backup-restore.md §4–5
Atlas outagestatuses: /api/ready; recover via Atlas console; app auto-recovers (drivers retry)