Angular (production): Cannot GET /dashboard — 404 when refreshing or opening a deep link
The web server only knows index.html; a direct request to /dashboard is not a file, so it returns 404 instead of letting Angular's router handle the URL.
Cannot GET /dashboardCannot GET /route404 on refresh AngularThe requested URL was not found on this server Angular routeAngular deep link 404 Meaning
Angular is a single-page app: every path must return index.html and the router takes over in the browser. Configure the server (Nginx try_files, Apache rewrite, Express *, S3/CloudFront error document) to fall back to index.html, or use hash routing as a quick workaround.
Common causes
- Nginx/Apache not configured with an SPA fallback
- Express serving
distwithout a catch-all route - S3/CloudFront with no 403/404 →
/index.htmlrewrite - Wrong
<base href>in a sub-folder deployment - Firebase/Netlify/Vercel without a rewrite rule
⚡ Quick fix
- Add the fallback to
index.htmlon your server - Check
<base href>matches the deployment path - Temporary:
provideRouter(routes, withHashLocation())
Detailed fix by platform
Nginx
location / { try_files $uri $uri/ /index.html; }
Apache
RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^ index.html [L]
Angular
ng build --base-href /app/when the app is not served from the domain root
Code examples
SPA fallback
server {
root /var/www/app/browser;
index index.html;
location / {
try_files $uri $uri/ /index.html; # unknown paths go to Angular's router
}
}How to diagnose
- Server — Which web server serves the build?
- Fallback — Rule to index.html present?
- Base — Correct base href?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Angular
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 15 Oct 2026