404 on page refresh (history mode) Vue Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

Browser: Cannot GET /users/42 — refreshing a Vue Router history-mode page returns 404

In history mode the server must serve index.html for all routes; otherwise direct URLs/refreshes hit non-existent files.

Exact message you may see Cannot GET /users/42 Vue Router history mode refresh404 Not Found on refresh Vue RouterVue Router history mode 404 on page refreshVue SPA 404 after refresh nginxvue-router history mode not working in production
Seen on: Vue Nginx

Meaning

Add an SPA fallback: Nginx try_files $uri $uri/ /index.html;, Apache .htaccess rewrite to index.html, Netlify _redirects /* /index.html 200, Firebase rewrites, S3/CloudFront custom error response 404→200 /index.html. Or use createWebHashHistory. Set base if hosted in a subfolder.

Common causes

  • Static server without fallback
  • Wrong base (subdirectory deploy)
  • Nginx try_files missing
  • CDN returning 404 for unknown paths
  • Assets requested relative to route path

⚡ Quick fix

  1. Nginx: location / { try_files $uri $uri/ /index.html; }
  2. Netlify _redirects: /* /index.html 200
  3. Set base/publicPath correctly or use hash history

Detailed fix by platform

Nginx

  1. location / { root /var/www/app; try_files $uri $uri/ /index.html; }

How to diagnose

  1. Server — Fallback?
  2. Base — Subfolder?
  3. CDN — Error rewrite?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

[Vue Router warn]: No match found for location with path — Vue Router: [Vue Router warn]: No match found for location with path "/users/42" (Vue)[Vue Router warn]: No…ChunkLoadError — ChunkLoadError: Loading chunk 123 failed. (JavaScript)ChunkLoadErrorCould not find a production build in the '.next' directory — Next.js: Error: Could not find a production build in the '.next' directory. Try building your app with 'next build' before starting the production server (Next.js)Could not find a prod…Failed to fetch dynamically imported module / async component failed — Vue: TypeError: Failed to fetch dynamically imported module: https://app.example.com/assets/Settings-abc123.js (Vue)Failed to fetch dynam…Failed to find Server Action — Next.js: Error: Failed to find Server Action "abc123". This request might be from an older or newer deployment (Next.js)Failed to find Server…Firebase Hosting: Page Not Found on refresh (SPA routes) — Firebase Hosting: Page Not Found — This file does not exist and there was no 404.html or index.html found in the document root (Google Cloud / Firebase)Firebase Hosting: Pag…injection "Symbol(router)" not found / useRouter() called without router — Vue Router: [Vue warn]: injection "Symbol(router)" not found. / Cannot read properties of undefined (reading 'push') (Vue)injection "Symbol(rou…MIME type not executable — Refused to execute script from 'x' because its MIME type ('text/html') is not executable (JavaScript)MIME type not executa…404 on pa…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.