How I Fixed the “Killed” Error When Deploying a Nuxt App on a 1 GB Server
The Problem
When deploying my Nuxt 4 site on a Forge-managed Ubuntu server (1 GB RAM / 1 vCPU / 25 GB SSD), everything looked fine until the final build step:
> nuxt build
[nuxi] Nuxt 4.2.0
ℹ Building for Nitro preset: node-server
Killed
=> Deployment failed: An unexpected error occurred during deployment.
No stack trace, no error message, just “Killed.” That message doesn’t come from Node or Nuxt. It comes from the Linux kernel itself.
What Actually Happened
Linux has a built-in safety mechanism called the OOM-killer (Out-Of-Memory killer).
When your system runs out of memory, the kernel doesn’t freeze, it kills the process using the most memory (in this case, node).
To confirm it, check the system logs:
sudo grep -Ei "out of memory|killed process|oom" /var/log/syslog
Example output:
Out of memory: Killed process 69039 (node) total-vm:56465872kB, anon-rss:665976kB, ...
This means your build consumed around 700 MB of RAM, the system had no memory left, and Linux terminated Node to save itself.
Why Nuxt Builds Use So Much Memory
Nuxt 4 builds rely on Vite for the client-side and build process, and Nitro (which uses Rollup internally) for the server output. These steps are memory-intensive and typically require 1.5–2 GB of RAM during build time. A 1 GB VPS simply cannot handle that without help.
The Fix: Add Swap and Increase Node’s Heap Size
The solution is to increase available memory through swap space and allow Node to use more heap memory during builds.
Step 1: Add Swap Memory
Swap acts as virtual memory on disk. When RAM fills up, Linux moves inactive data into swap space instead of killing processes.
Run these commands:
sudo swapoff -a
sudo rm -f /swapfile
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Then verify:
free -h
You should see something like:
Swap: 4.0Gi 64Mi used 3.9Gi free
If the total is around 4.0 Gi and it shows a small amount of usage, swap is active and working.
Now your 1 GB server effectively has around 5 GB of usable memory (1 GB RAM + 4 GB swap).
Step 2: Increase Node’s Heap Size
Even with swap, Node has its own memory limit (around 1.5 GB by default). During large builds, this limit can cause Node to crash with an OOM error even if swap is available.
To fix it, you can raise the limit by setting an environment variable before running your build.
Add this line at the top of your Forge deploy script (before npm ci or npm i):
export NODE_OPTIONS="--max-old-space-size=3072"
This command increases Node’s maximum heap allocation to around 3 GB.
If your build is still memory-hungry, you can go higher:
export NODE_OPTIONS="--max-old-space-size=4096"
These values tell Node how much memory it can use before triggering garbage collection or being killed by the kernel.
Optional: Build Before Deploying
If your VPS is still struggling, avoid building on the server. Build locally or in CI (for example, GitHub Actions), and upload only the .output/ directory to the server. The server will then only run the app, not compile it.
Takeaways
- The “Killed” error almost always means the process ran out of memory, not that your code is broken.
- A 1 GB server cannot handle Nuxt or Node builds without swap.
- Adding swap and increasing Node’s heap limit is an easy, cost-free solution.
- For long-term stability, either upgrade to a 2–4 GB server or pre-build your app before deployment.
Useful Commands Recap
# Check current memory usage
free -h
# Check which process was killed
sudo grep -Ei "out of memory|killed process|oom" /var/log/syslog
# Add 4 GB swap
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# Increase Node heap size for the build
export NODE_OPTIONS="--max-old-space-size=3072"
Final Thoughts
This wasn’t a Nuxt or Forge issue, it was a system memory limitation. The OOM-killer did exactly what it’s designed to do. By adding swap and configuring Node’s heap size properly, you can deploy even heavy builds on small servers.
If you’re running a VPS with 1 GB RAM, set up swap right now. It costs nothing and prevents hours of confusion the next time your deployment ends with one word: Killed.