Getting 500 errors instead of 404 errors for unknown urls in directories with dynamic urls


Our site uses dynamic pages i.e. blog/[post], resources/[resource] etc, as well as at the root directory ( /[slug] ).

When entering a URL within these directories that does not match a valid page (e.g. blog/asdfadf), the site displays the 500 error page.
The expectation is that it should show a 404 page.

When entering an invalid page in an unknown directory, the site correctly displays the 404 page.

Our site uses getStaticPaths for all dynamic routes

We do have a redirects file but removing it entirely makes no difference to the result here. I tried adding manual 404 redirects for the dynamic directories but it broke things at the root directory and I received warnings of conflicts for the other directories.

Is this expected behaviour or is there anything I can do to make invalid URLs at the dynamic directory display a 404 instead of 500 error?


Hey @ao-olia,

This is most likely a bug with the plugin which could be related to: [Bug]: Fallback false is ignored · Issue #1179 · netlify/netlify-plugin-nextjs · GitHub

Thank you @hrishikesh I have subscribed to that thread

1 Like