Stuck on Creating an optimized production build forever when development server is running
#60147
Replies: 92 comments 26 replies
|
Facing the same issue |
|
i have same issue !! |
|
Execute the steps of “ creating an optimized production build ” on the Linux server node v14.17.0 |
|
same issue |
|
Same issue for us |
|
The same issue still exists.... any remedies. In my case, it was hours I stuck at this "creating an optimized production build". And also I didn't run the development server in the background. |
|
same issue! |
|
Same issue for React.js project as well even when development server is not running on |
|
I have the same issue!!! |
|
Same Issue. In development it worked, but when I try to create the Docker image it stuck |
I solved with the next steps:
|
Same issue but I wasn't aware that this was happening due the open dev webserver. So the solution for me is on your title: close the development server, then run |
|
I am still facing the same issue. Using the latest NextJs 12.3.2-canary.34 facing this issue since I'm trying 12.3.2-carany.+ |
|
You can't have both dev and build at the same time. I solved it very quickly when I realized that there were several nodejs processes open when there should only be 1, and killing all the nodejs processes that were running in the background solved it for me.It can also happen that a build started to fail and got stuck in the background so you should kill all the nodejs you see running in the task manager. I am using Nextjs 13 |
|
Mine was also solved. I faced this issue because a dependency wasn't comfortable with the latest nextjs. 🙃 |
|
+1 |
|
In my case, it works fine when I run build on my local machine but it gets stuck forever when building docker image. I was using "oven/bun" as my base docker image and I suspected that the issue is from bun's image. So, I switched to "node:20.11.1-slim" base docker image and I ran "npm install -g bun" in my Dockerfile to install bun and it worked like a charm! I hope this helps someone |
|
After trying all recommendation here and all are not working, I just found out the reason after 2 weeks of debugging is Hope this helps you guys, cheers! |
|
Make sure to stop the localhost and remove the current .next file. |
|
I got a great solution that is not to use this kind of problematic framework anymore. I hope this helps someone |
|
I had this issue on DigitalOcean and AWS EC2 instances. Turns out it was simply RAM running out since the instances were 2GB RAM. After Resizing/upgrading to 4GB RAM, build worked well for me. Posting this in case this is the issue for some people. |
|
This problem keeps cropping up and can take hours of valuable time to track down. I suggest that Next.js provide more verbose logging to their build process. Right now it's a black box guessing game of "why does the build hang this time". Should not be difficult to add verbose build logging. In the past I've had to reboot for the build to work !?!. Now the reboot trick doesn't work. |
|
I think the issue is next/font /google build in next js package. i just comment google font coding part.. everything working . |
|
Just want to add another edge case here for future reference if any of the above doesn't work. I'm using the n package manager and I thought I was changing my local node version to a lower version that was compatible with the next build but it turns out I wasn't because my node version was being managed by homebrew instead of n. See this thread for reference or just run 'brew unlink node' and try again. |
|
Removing |
|
I'm here because 4 of my projects are stuck on this command w/o any code update... I fixed it, as mentioned above, by raising the memory |
|
Hey guys, if anyone is still stuck on this, I found that I was getting it because I didn't add |
|
In my case, I fixed it because I had an import from |
|
remove the old .next folder and then run npm run build this works for me after a lot of tries. |

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Verify canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 16.13.0
npm: N/A
Yarn: N/A
pnpm: 6.24.0-1
Relevant packages:
next: 12.1.4
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
I had my development server running in the background without me remembering and I wanted to build my app using
next build, that's what I've got:And I was stuck for 30 minutes on
info - Creating an optimized production buildwithout any indication of anything being wrong, I noticed that the development server was running, after I've shut it down and rannext buildagain It compiled successfully.Expected Behavior
Run
next buildto compile the app for production even when I'm running the development server.OR
Notify me that the development server is running and needs to be shut down before running
next build, that's in case runningnext buildwhennextis running isn't possible.Link to reproduction
https://github.com/YassinEldeeb/Next.js-starter
To Reproduce
nextfor the development server.next buildwhile the development server is running.Note: It's not specific to the repository linked above.
All reactions