If you are exporting statically there are some limitations with app/not-found.tsx Because it only works for server rendering or dynamic pages, so you need to use app/404.tsx for static export instead. This will generate 404.html after build.