-
Notifications
You must be signed in to change notification settings - Fork 26.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PORT env var is not respected when set in .env file #32603
Comments
This is actually not a bug, booting the http server asap has the highest priority in |
Ok, yeah, especially since you have a .env file example with |
That example is constructing an external API url. But can be changed |
Reading all
↓
I just ran What’s the practical benefit of launching the server before loading |
With normal file reading in Node.js we already see it taking upward of 10ms+ per-file depending on how much is going on in the main thread, so it'll significantly slow down bootup. |
Will, I don't care about 1000ms so would you please add an option for those like me who don't care 😕 Also, I don't think anybody would care about 1000ms in ((production)) For development you could cache it or something like that or make it a production thing |
Sorry for the tuff language but I am not a native speaker and I don't know how to deliver my thoughts better than that 😅 |
@timneutkens How about adding an option to read .env before starting? #44392 |
Good callout,@mbohgard. I've made a PR (#51063) for removing The documentation regarding port customization has already been updated with a note that using |
This is to [avoid confusion](#32603 (comment)) about being able to set Next.js's port via `.env`, which is currently not allowed.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
12.0.7
What version of Node.js are you using?
14.17.6
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
N/A
Describe the Bug
Setting
PORT=4000
for ex is not respected when set in .env, .env-development etc .env files.Loggin out
process.env.PORT
in next.config.js is reporting the correct port (4000) but the server is still starting on port 3000 (default).The behaviour is the same with
next dev
andnext start
.Expected Behavior
The server should use PORT from .env files as when started with
PORT=4000 next dev
.To Reproduce
PORT=4000
.next dev
.The text was updated successfully, but these errors were encountered: