# Bun hosting in 2026: how to run a Bun server on Livops

> Bun is not a separate preset. A Node project that uses Bun, through a bun lockfile, a packageManager of bun or Elysia, is started with bun, so Bun.serve and bun:sqlite work. Livops picks the start command from your package.json or your TypeScript entry file.

Source: https://livops.dev/en/hosting/bun-hosting

By Livops team, the people who build and run Livops. Updated 28 November 2026.

Bun does not get its own preset on Livops. A Node project that uses Bun is built as a Node project, and only the command that starts it changes. The reason is practical: Bun runs TypeScript directly and provides `Bun.serve` and `bun:sqlite`, which do not exist under plain Node. So the start command must run under `bun`, or the app would crash on its first request.

## How Livops decides

Livops treats the project as a Bun project when any one of these is true:

- a `bun.lock` or `bun.lockb` file is in the repository
- `package.json` has a `packageManager` field that starts with `bun@`
- the project depends on `elysia`, which runs on Bun only
- the `start` script begins with `bun `

## The start command

- If `package.json` has a `start` script, Livops runs `bun run start`. On a build image that has no Bun, it falls back to `npm run start`.
- If there is no `start` script, Livops runs `bun` on the first of these files that exists: `src/index.ts`, `index.ts`, `src/server.ts`, `server.ts`, `src/main.ts`, `main.ts`, `src/app.ts`, `app.ts`.

Bun runs `.ts` files itself, so a project with no build step can start from its TypeScript source.

## The port

Read `PORT` from the environment and listen on it. In Bun that is `Bun.serve({ port: Number(process.env.PORT) || 3000 })`. Do not hard-code a port. A fixed port makes the app unreachable on Livops.

Set the health check path to `/`, or to a page that always answers.

## Telegram bots

A Telegram bot on Bun with `grammy` or `telegraf` is a bot, not a web server. It dials out to Telegram, so it needs no port and no health check page. Follow [Grammy bot hosting](https://livops.dev/en/guides/grammy-bot-hosting) for the bot-specific settings.

## Environment variables

Put secrets and settings in the Variables section of the cabinet. Read them with `process.env` or `Bun.env`. A change takes effect after a restart.

## Common mistakes

- **A `start` script that runs `bun --watch`.** The watcher is for your laptop. Use a plain `bun run` of the entry file in the start script.
- **A hard-coded port.** Read `PORT`.
- **Relying on a lockfile you did not commit.** Commit `bun.lock` so the install matches what you tested.
- **Bun APIs with no Bun detection rule.** If the code uses `Bun.serve` or `bun:sqlite` but none of the rules above match, Livops starts it with Node and it crashes. Keep one of them true, usually the `bun.lock` you commit.

## Questions

**How does Livops know my project uses Bun?**

From any one of these: a bun.lock or bun.lockb file, a packageManager field that starts with bun@, the elysia dependency, or a start script that begins with bun. Any one is enough.

**Which command starts a Bun project?**

If the package.json has a start script, bun run start, and npm run start on an image that has no bun. If there is no start script, bun on the first TypeScript entry it finds, in this order: src/index.ts, index.ts, src/server.ts, server.ts, src/main.ts, main.ts, src/app.ts, app.ts.

**Is a Bun app free on Livops?**

A Bun server is a web app, a process that stays up, so it is paid by the memory it uses.

## Sources

1. [Bun — Documentation](https://bun.com/docs). Checked 28 November 2026.
2. [Bun — Run a file](https://bun.com/docs/cli/run). Checked 28 November 2026.
