12 Key Lessons for Self-Hosting Next.js on a VPS Instead of Vercel
Developers migrating Next.js applications from Vercel to a self-managed Ubuntu VPS encounter several non-obvious configuration challenges that can cause failures in production. Process management requires PM2 with a systemd startup hook, as skipping the latter means all running processes are lost on server reboot. Nginx must be configured to handle WebSocket upgrades, raise the default 1MB body size limit, and disable proxy buffering for streaming responses. SSL setup via Certbot requires DNS A records to be verified in advance, UFW firewall rules must include SSH before the firewall is enabled, and certificate auto-renewal should be tested with a dry run. Additionally, installing the sharp package is critical for Next.js image optimization on a VPS, since the fallback JavaScript-based optimizer can spike CPU usage to 100% on low-cost servers.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in