Skip to main content

Deploy Bun Apps

Bun is a recently popular Node alternative for back-end Javascript runtime environment. Like Node, you don't need to compile your code beforehand.

There is no default bun compiler at system level. You have to install it first through deployment scripts.


Serving Bun apps requires to be run via GLS, that's mean you have to listen from given PORT env/args. Bun.serve is already doing this if you don't set the port explicitly.


The deployment script below installs the latest bun compiler and writes app.ts and serves that.
source: clear
- bun latest
root: public_html/public
enabled: "on"
app_start_command: env PORT=$PORT bunfix bun app.ts
- filename: app.ts
content: |
const html_text = `
<!DOCTYPE html>
<title>Bun App</title>
<link rel="stylesheet" href="//">
<body class="p-5 text-center">
<p><img src="//"
class="img-fluid rounded-circle"></p>
<h1 class="mb-3">Hello, world!</h1>
<p>Serving from Bun version ${Bun.version}</p>
<p class="text-muted">DOM Cloud</p>
const server = Bun.serve({
fetch(request) {
return new Response(html_text, {
headers: { "Content-Type": "text/html" },

Note three things:

  • Bun.serve already set the port arg from PORT env by default
  • bunfix bun app.ts is used to run Bun with a workaround of an ongoing issue
  • This bunfix proxies request to the bun app, this proxy support HTTP and Websocket

For existing bun apps, use this deployment script. Please adjust relevant fields such as the startup file (change app.ts) and how $PORT is delivered (via env PORT=$PORT bunfix bun ...).
- bun latest
root: public_html/public
enabled: "on"
app_start_command: env PORT=$PORT bunfix bun app.ts

Use other Bun versions

To switch Bun version use feature syntax like bun latest, bun beta, bun 1.0.0, etc. Check your current Bun version using bun --version in SSH.

- bun 1.0.0

Bun install scripts is powered by webi.

App Management

Your app do not restarted automatically after file changes. To restart, run restart via SSH.

Environment variables can be set either using NGINX's env_var_list or ~/.bashrc. Usually your language framework also reads .env files.

See NGINX and App Daemon for more information about NGINX and App managements including restarting, environment variables, and other global limitations.

App Logging

You can see app log from Check -> Check Process Logs tab. Only startup problems displayed in the browser.

Bun can show runtime errors in browser by setting app_env: development in the passenger config of NGINX.

It's recommended to use a proper logging mechanism such as Pino or Winston then write it to a log file, or any other solution that suits you.

NGINX errors and traffic logs can be examined via Webmin or Check -> Check Process Logs tab.