You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been experiencing a strange issue with a NextJS app running on my web server. I launch it using pm2, which in turn uses the command npm start (I run npm run build first).
When I start the process, the page is online and accessible for some period of time, usually a few days. But then, at some point, when I go to check on it, I get a 502 Bad Gateway error instead. The NextJS error logs show this error:
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:387:5)
at URL.onParseError (node:internal/url:564:9)
at new URL (node:internal/url:644:5)
at Object.fn (/home/mainuser/personal-page/node_modules/next/dist/server/next-server.js:995:43)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Router.checkFsRoutes (/home/mainuser/personal-page/node_modules/next/dist/server/router.js:191:31)
at async Router.execute (/home/mainuser/personal-page/node_modules/next/dist/server/router.js:340:36)
at async NextNodeServer.handleUpgrade (/home/mainuser/personal-page/node_modules/next/dist/server/next-server.js:578:9) {
input: 'undefined',
code: 'ERR_INVALID_URL'
}
This is especially strange to me, because I also have a NextJS web app running on the same web server, and it continues to be accessible.
Furthermore, the site/app that's breaking has a rewrites() method set up that redirects certain requests to the working web app. This leads me to think that while the site itself is refusing to load, enough of the NextJS web server is working that it can reroute certain URL requests to the secondary app, so the whole thing isn't going down. I see my nginx configuration also has stuff set up to direct to this web app, so it's possible that the NextJS rewrites() method isn't actually doing anything.
Key points (in my opinion, so far):
The primary app is online and accessible for a period of time after launching it. Only after a while does it stop working and give a 502 error.
The primary app is just a "portfolio page" for me, without any account systems, APIs, or services. Meanwhile, the secondary app does work with requests and APIs. Despite this, the primary app has been going offline consistently, while the secondary app has remained stable.
Please let me know if there's any other info that would be important or relevant here! I'm not primarily a web developer or server IT person, so a lot of this stuff is a bit arcane to me 😅
Thanks!
Additional information
My config file that redirects certain URLs to my secondary app (called "Countinator"):
Operating System:
Platform: linux
Arch: x64
Version: #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 16 13:30:11 UTC 2023
Binaries:
Node: 18.7.0
npm: 8.18.0
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.4.1
eslint-config-next: 13.4.1
react: 18.2.0
react-dom: 18.2.0
warn - Latest canary version not detected, detected: "13.4.1", newest: "15.5.1-canary.27".
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue
I can try running the app with the canary version to see how it does, but as stated before, I doubt this would be an issue because my secondary app has been running on 13.3.1, and has not had any of these crashing issues.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I've been experiencing a strange issue with a NextJS app running on my web server. I launch it using pm2, which in turn uses the command
npm start
(I runnpm run build
first).When I start the process, the page is online and accessible for some period of time, usually a few days. But then, at some point, when I go to check on it, I get a 502 Bad Gateway error instead. The NextJS error logs show this error:
This is especially strange to me, because I also have a NextJS web app running on the same web server, and it continues to be accessible.
Furthermore, the site/app that's breaking has aI see my nginx configuration also has stuff set up to direct to this web app, so it's possible that the NextJSrewrites()
method set up that redirects certain requests to the working web app. This leads me to think that while the site itself is refusing to load, enough of the NextJS web server is working that it can reroute certain URL requests to the secondary app, so the whole thing isn't going down.rewrites()
method isn't actually doing anything.Key points (in my opinion, so far):
Please let me know if there's any other info that would be important or relevant here! I'm not primarily a web developer or server IT person, so a lot of this stuff is a bit arcane to me 😅
Thanks!
Additional information
My config file that redirects certain URLs to my secondary app (called "Countinator"):
Running
npx next info
:I can try running the app with the canary version to see how it does, but as stated before, I doubt this would be an issue because my secondary app has been running on 13.3.1, and has not had any of these crashing issues.
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions