Next.js Discord

Discord Forum

i need help using pm2

Unanswered
Whiteleg shrimp posted this in #help-forum
Open in Discord
Avatar
Whiteleg shrimpOP
so i'm trying to use pm2 on my next js project, managed to use it bu running pm2 start ./node_modules/next/dist/bin/next --name "appName"
but i want to set port

8 Replies

Avatar
joulev & fuma pray for Schneider
idk about pm2 but if you want to set the port name i think you can set the PORT env var or use --port
./node_modules/next/dist/bin/next --name "appName" --port 8080
Avatar
European sprat
yeah i explained this the other day but they never mentioned if it worked or not
if --port 8080 doesn't work, try what i had originally said

PORT=8080 pm2 start ./node_modules/next/dist/bin/next --name "appName"
Avatar
Whiteleg shrimpOP
they both do not work
Avatar
European sprat
I guess you're out of luck then
Another solution could be directly modifying the server files where the port is defined but that's out of scope and unsupported
The alternative is use a standalone build which uses nodejs to run the server and you can easily set the port