Deploying Next.js and Strapi on shared Node hosting: four walls we hit
Moinul Hossain Miraj · · 4 min read · Web Development

Running a Next.js website and a Strapi CMS together on a managed Node host sounds simple: push the code, the host installs and starts it. In practice we spent days on four failures that all looked like bugs in our own code. None of them were. Here is what each one looked like, what was really going on, and how we fixed it.
1. "Failed to load native binding" when building the Strapi admin
The Strapi admin build stopped every time with:
Error: Failed to load native binding
at .../node_modules/@swc/core/binding.jsWe reinstalled packages, cleared caches, and deployed from a fresh clone. Same error. The native file was there, with the right version for the server, and normal permissions.
The useful step was to stop guessing and ask the system directly. A few lines of Node called the loader by hand and printed the real reason, which the library was hiding:
try { process.dlopen({ exports: {} }, file); }
catch (e) { console.log(e.message); }The answer: recent SWC versions copy their native file into a cache folder before loading it. That folder must be owned by the current user with permissions 0700, or SWC refuses it. The fallback location was /tmp, and on this host /tmp is mounted noexec, so nothing can be loaded from it either.
The fix was one environment variable, set before the build starts, pointing SWC at a folder we create ourselves:
const dir = path.join(__dirname, ".swc-native-cache");
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
fs.chmodSync(dir, 0o700);
process.env.SWC_NATIVE_BINDING_CACHE = dir;Lesson: when a library says "failed to load", load the file yourself and read the operating system's message. It usually names the real problem.
2. A build that never finishes in time
Shared Node hosts usually build inside npm install, with a time limit. Ours killed an install after 15 minutes and stopped the whole deploy at about 25. A clean install, the Strapi admin build and the Next.js build added up to more than that on a busy day.
We tried to make the build faster. That helped a little, but the real fix was to stop putting everything inside the deploy:
- The deploy builds only the CMS admin panel and finishes.
- When the app starts, the CMS starts first, so editors can work right away.
- The app then builds the website itself, where there is no time limit, and shows a short "starting" page until it is done.
A deploy now ends in about 10 minutes, and a slow build no longer fails the whole release.
Lesson: if a platform limit keeps cutting your build off, move the slow part out of that limit instead of fighting the clock.
3. Two builds at once, both killed
After one failed deploy, things got worse. The logs showed builds starting over and over, each killed with SIGKILL, and compile steps going from 12 seconds to over 100.
The cause: saving a setting on the host restarted the running app before the new build existed. The restarted app found no website build and started building one itself, at the same moment as the deploy's build. Two heavy builds on one machine starved each other of memory, got killed, restarted, and started again.
Two changes stopped the loop:
- If the CMS is already built, a starting app never builds the CMS again.
- The website build at start takes a lock file with its process ID, so a second copy of the app does not start a second build next to it:
const lock = { pid: process.pid, at: Date.now() };
fs.writeFileSync(lockFile, JSON.stringify(lock));
// another instance checks the pid with process.kill(pid, 0) and waitsLesson: "it fails, then fails faster" often means two copies of something are fighting. Look for overlapping start times in the logs.
4. "Access denied" from MySQL with the right password
The CMS could not connect to MySQL:
Access denied for user 'app'@'::1' (using password: YES)The password was right. The clue is ::1: that is IPv6 localhost. Node 17 and later resolve localhost to ::1 first, and the database user on this host was only allowed to connect from the IPv4 address 127.0.0.1. To MySQL, those are different hosts.
The fix: use 127.0.0.1 instead of localhost in the database settings. We also made the config turn localhost into 127.0.0.1 automatically, so the next person does not hit it:
host: env("DATABASE_HOST", "127.0.0.1").replace(/^localhost$/, "127.0.0.1"),Lesson: when MySQL says access denied, read the host part of the message, not just the user name.
What we would tell anyone doing this
- Print the real error before changing anything. Two of these four looked like one problem and were another.
- Know your platform's limits (time, memory, mounted folders) before you design the build.
- Read the whole log line.
::1,noexecandSIGKILLeach told us exactly where to look.
We use AI coding tools to build faster, and every fix above was reviewed by an engineer before it went live. If you are moving a Next.js or Strapi project to production and want a second pair of eyes, get in touch.


