<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@500&family=IBM+Plex+Sans:wght@400;500;600&family=Instrument+Sans:wght@600;700&family=Noto+Sans+Georgian:wght@400..700&display=swap"> Skip to content
Binwi logo

Run a Node.js app

In the examples, svm123 is your username and SERVER_IP is your server address — both are on the Access tab of your SVM in the console.

Run the app as a service that starts on its own and stays up after you log out, then point nginx to it:

# 1. the app: listen on the socket (or port) it is given
cd ~/apps && git clone https://github.com/you/app.git myapp && cd myapp
npm install
#    app.listen(process.env.SOCK || process.env.PORT)

# 2. keep it running, also after you log out and after reboots
cp ~/.config/systemd/user/app.service.example ~/.config/systemd/user/myapp.service
nano ~/.config/systemd/user/myapp.service      # WorkingDirectory=%h/apps/myapp
systemctl --user daemon-reload
systemctl --user enable --now myapp

# 3. send your domain to it
cp ~/nginx/conf.d/node-app.conf.example ~/nginx/conf.d/myapp.conf
nano ~/nginx/conf.d/myapp.conf                 # server_name example.com www.example.com;
systemctl --user reload svm-nginx

The example service gives the app a private socket in SOCK. If the app can only use a TCP port, use one of your own ports on 127.0.0.1 — shown on the Usage tab — and set PORT instead. Other ports are blocked.

Next.js

next start cannot listen on a socket, so give it one of your own ports (shown on the Usage tab) and point nginx at 127.0.0.1 on that port:

# ~/.config/systemd/user/mynext.service
[Service]
WorkingDirectory=%h/apps/mynext
Environment=NODE_ENV=production
ExecStart=%h/apps/mynext/node_modules/.bin/next start -p 10000 -H 127.0.0.1
Restart=on-failure

[Install]
WantedBy=default.target
# ~/nginx/conf.d/mynext.conf
server {
    listen unix:/run/svm/svm123/nginx.sock;
    server_name example.com www.example.com;
    location / {
        proxy_pass http://127.0.0.1:10000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}
npx next build --webpack            # not Turbopack — see below
systemctl --user daemon-reload
systemctl --user enable --now mynext
systemctl --user reload svm-nginx

Build with webpack, not Turbopack. Next.js 16 uses Turbopack by default, and Turbopack talks to its helper processes over random local ports — on SVM each account may only use its own ports, so a Turbopack build stops with “binding to a port: Operation not permitted”. The webpack build produces the same result. Easiest is to put the flag in package.json:

// package.json — so npm run build / npm run dev work as usual
"scripts": {
  "dev": "next dev --webpack",
  "build": "next build --webpack",
  "start": "next start"
}

Building needs more memory than running: allow about 1 GB for next build, while the running app needs around 150 MB. If a build is stopped with “Killed”, it ran out of the plan's memory — build on your computer and upload the project with its .next folder, or use a larger plan. Pages that fetch from your own API while building need that API to be working.