Fixing “WebAssembly.Instance(): Out of memory” Error in cPanel for Next.js/React.js Builds

If you’re building a Next.js or React.js application using the cPanel terminal and see the error “RangeError: WebAssembly.Instance(): Out of memory: Cannot allocate Wasm memory for new instance,” it means the build process needs more memory than cPanel is currently allowing.

Here’s how to fix this if you have WHM (WebHost Manager) access.

What Causes This Error?

Modern JavaScript applications, like those built with Next.js or React.js, can use a lot of memory during their build process. Sometimes, the tools they use (which might include WebAssembly for speed) try to use more memory than the limit set for a single process in your cPanel settings. When this happens, the build stops and shows the “Out of memory” error.

How to Fix It: Increase cPanel Process Memory Limit

You can solve this by increasing the maximum amount of memory a cPanel process can use. You’ll do this in WHM’s Tweak Settings.

  1. Log into WHM: Open your WHM panel. You usually do this by going to yourdomain.com/whm or yourserverip:2087 and logging in.
  2. Go to Tweak Settings: In WHM, look for “Tweak Settings.” You can often find it by typing “Tweak Settings” into the search bar.
  3. Find “Max cPanel process memory”: On the Tweak Settings page, you need to find the setting called “Max cPanel process memory.” You might see a note that the minimum is 4,096 MB.
  4. Increase the memory limit: You’ll need to increase the number in this field. The default or current setting might be too low for your application’s build process.
    • Try increasing it. For instance, if your server has enough resources, you could try 8,192 MB (8GB).
    • The exact amount you need can vary. If you still get the error, you might need to try a slightly higher value.
    • Be careful: Don’t set this value too high, as it could affect your server’s overall performance if other services don’t have enough memory. Keep an eye on your server’s total RAM usage.
  5. Save your changes: After changing the value, scroll down and click the “Save” button.

After you save the new setting, go back to the cPanel terminal and try building your Next.js or React.js application again. This should usually fix the “WebAssembly.Instance(): Out of memory” error.

In Short

This memory error happens when your application build needs more resources. Increasing the “Max cPanel process memory” through WHM Tweak Settings generally resolves the issue by giving the build process the memory it requires.

How to Uninstall Let’s Encrypt from Cpanel / WHM

To uninstall the Cpanel / WHM plugin for Let’s Encrypt, login to your SSH for root and run the following:

/usr/local/cpanel/scripts/uninstall_lets_encrypt_autossl_provider

It might take sometime, once completed, it should remove let’s encrypt as a provider from your AutoSSL plugin.

How to Skip WHM Initial Setup Wizard When Stuck After Upcp

If you have recently ran upcp and the WHM initial setup wizard is stuck in a URL like the following:

https://yourhostname.com:2087/cpsess*****/scripts/initial_setup_wizard1

And can not get away with it, here is the easy way to do it. Basically each setup wizard has a skip button and the button goes to initial_setup_wizard1_do, so only adding the _do at the of your initial_setup_wizard1 should do the job, like the following:

https://yourhostname.com:2087/cpsess*****/scripts/initial_setup_wizard1_do/

This should take you to the WHM home by letting you save some of the new WHM features and will not ask again for initial setups.