#I face server error 504 for my next js on vps server (nginx)
1 messages · Page 1 of 1 (latest)
The 504 error you're facing might be due to a FUNCTION_INVOCATION_TIMEOUT error, which occurs when the request for a Serverless Function reaches the timeout threshold. This is an application error.
A common cause for this issue is when the application contains an unhandled exception. You can check the application logs for more information. In the case of a Vercel deployment, the logs can be found at the host URL under the /_logs path, for example:
https://my-deployment-my-username.vercel.app/_logs
(Source: Vercel Application Error Codes (https://vercel.com/docs/errors/application-error-codes))
To handle unhandled exceptions, you can customize the 500 page (https://nextjs.org/docs/advanced-features/custom-error-page#500-page) in your Next.js application. Additionally, you can log and track exceptions with a tool like Sentry. There's an example (https://github.com/vercel/next.js/tree/canary/examples/with-sentry) that shows how to catch & report errors on both the client and server-side using the Sentry SDK for Next.js.
(Source: Next.js Going to Production (https://nextjs.org/docs/going-to-production))