Production Port in Pterodactyl [ SOLVED ]
Hey all, I'm trying to change the production port in Nuxt3. It's easy to set for development but how can I do this for prod. I'm using Pterodactyl for all of my containers. I'm using the NodeJS:21 configuration and I can only set the
./<path>/index.mjs
and environment arguments what could be --port="3005"
as an example but that doesn't work.
How can I set the port for production?3 Replies
Hi @Spctr. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To set the port for production in Nuxt 3, you can use environment variables. Nuxt respects certain environment variables for configuring the server in production. Here's how you can set the port:
1. Use the
NITRO_PORT
or PORT
environment variable:
When running your Nuxt 3 application in production, you can set either the NITRO_PORT
or PORT
environment variable to specify the desired port. For example:
or
This approach is mentioned in the Nitro documentation Deploy > Runtimes > Node.js (https://nitro.unjs.io/deploy/runtimes/node).
2. If you're using Pterodactyl and can set environment variables, you should be able to set the PORT
or NITRO_PORT
variable there.
3. If you can't set environment variables directly, you might be able to modify your start command to include the port. For example:
Remember that after building your Nuxt 3 application for production, the .env
files are not used. You need to set the environment variables explicitly when running the server, as mentioned in the Nuxt documentation Docs > Guide > Directory-structure > .env (https://nuxt.com/docs/guide/directory-structure/env#production).
If you're still having issues, you might need to check your Pterodactyl configuration to ensure it's properly passing environment variables or allowing you to set the start command with the necessary parameters.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@320895029008793600> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
That doesn't work for Pterodactyl but I've found a workaround.
Just put this file in the
/home/container
: