← Back to all fixes
Static files return 404 through nginx
The Issue
HTML loads but all linked CSS and JS return 404.
Root Cause
The `root` or `alias` path in the nginx config points to the wrong directory, or the location block for static files is missing.
How to Fix
Check the `root` directive in your nginx server block — it must point to the directory containing static filesIf serving from `/public`: `root /var/www/myapp/public;`Add explicit location for static extensions if needed: `location ~* \.(css|js|png)$ { root /var/www/myapp/public; }`Verify file actually exists on disk at the expected pathCheck nginx access log to see exact path being requested: `sudo tail -f /var/log/nginx/access.log`