# Development Server

> Serve files with live reload, run fetch handlers, and replicate a server across contexts.

```bash
elide dev ./public
elide serve ./dist
```

| Command | Default address | Watches files | Live reload |
| --- | --- | --- | --- |
| `elide dev` | `127.0.0.1:3000` | Yes | Static files only |
| `elide serve` | `127.0.0.1:8080` | No | No |

A directory subject starts a file server; a script subject runs as a program.

<img src="https://elide.help/assets/demos/dev-server.gif" alt="Starting the development server and observing a changed page" width="1591" height="691" loading="lazy" decoding="async" class="rounded-lg border border-border my-6 w-full" />

| Flag | Effect |
| --- | --- |
| `--host HOST` | Bind host. |
| `--port PORT` | Bind port. |
| `--no-tui` | Plain log output instead of the TUI. |
| `--no-watch` | `dev` only: no watching or reload. |
| `--contexts=N` | Run `N` copies of the app; `auto` sizes from the CPU cores. Linux only. |

## Fetch handlers

```js
// entrypoint.mjs
export default {
  async fetch(request) {
    return new Response("ok");
  },
};
```

```bash
elide serve entrypoint.mjs
```

`elide run entrypoint.mjs` also serves, on the exported `hostname` and `port` or `127.0.0.1:8080`.
`Elide.serve({ port: 3005, fetch })` uses its own address with every command.

## Replicated serving

```bash
elide serve --contexts=4 entrypoint.mjs
```

- Each context runs the entry module once and keeps its own globals; a request counter counts per context.
- A connection stays on one context for its lifetime, including keep-alive requests.
- If one context fails, the server stops.

Set `engine.contexts` in `elide.pkl` for finer control; see [Engine contexts](https://elide.help/docs/elide-pkl-reference#engine-contexts).
