> ## Documentation Index
> Fetch the complete documentation index at: https://docs.localdev.build/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI reference

> Flags, environment variables, exit codes and signals

## Usage

```
ldev [flags] <Projectfile>
```

* Exactly one Projectfile path. The path can be relative or absolute.
* **Flags go before the path.** Mistakes print a hint and the usage, and exit with code 2:

## Flags

| Flag | Default | Purpose |
| - | - | - |
| `-server` | `localhost:2345` | Address of the UI and API |
| `-collector-address` | `localhost:50000` | Where Localdev receives telemetry from the collector |
| `-store-logs` | `30000` | Log records kept in memory (1–10,000,000) |
| `-store-metric-points` | `1000000` | Metric points kept in memory (1–100,000,000) |
| `-store-trace-spans` | `50000` | Trace spans kept in memory (1–10,000,000) |
| `-verbose` | off | Debug logging from Localdev |
| `-version` | | Print the version and exit |
| `-h` | | Print the flags and exit |

`-collector-address` on all interfaces (`0.0.0.0:50000`, `:50000`) works: the collector connects
through localhost.

The UI answers only to `localhost`, IP addresses and the host name in `-server`. Opening it through any other host name (a `.local` name, or one from `/etc/hosts`) fails with `localdev: request rejected, unexpected Host header`. Use the IP address, or set that name in `-server`.

## Environment variables

These variables set the same sizes as the `-store-*` flags:

| Variable | Same as | Sets |
| - | - | - |
| `LDEV_STORE_LOGS` | `-store-logs` | Log records kept in memory |
| `LDEV_STORE_METRIC_POINTS` | `-store-metric-points` | Metric points kept in memory |
| `LDEV_STORE_TRACE_SPANS` | `-store-trace-spans` | Trace spans kept in memory |

An empty value counts as not set. An invalid value stops start-up, even if a valid flag is also given.

## Order of store settings

Each size is taken from the first of these that sets it: the flag, the environment variable, [`store`](https://docs.localdev.build/configuration/introduction#store) in the Projectfile, then the default.

## Exit codes

| Code | Meaning |
| - | - |
| 0 | Stopped normally, or `-version` / `-h` |
| 1 | Couldn't start: bad Projectfile, port in use, collector not found, invalid `LDEV_STORE_*` |
| 2 | Invalid flag or value, missing Projectfile, flags after the Projectfile |

## Signals

| Signal | Effect |
| - | - |
| Ctrl-C / SIGINT, SIGTERM | Stop services (SIGTERM, then SIGKILL after 5 s), then exit |
| Second Ctrl-C | Kill the services immediately |
| SIGKILL | The guard process stops the services |

## Examples

```sh theme={null}
ldev Projectfile
ldev /path/to/project/Projectfile
ldev -server localhost:8080 Projectfile
ldev -store-logs 100000 -store-trace-spans 200000 Projectfile
```

Running from another directory is fine. Services still run in the Projectfile's directory.

### Port already in use

Localdev stops at start-up if one of its ports is taken:

```
telemetry server (-collector-address): localhost:50000 is already in use (is another ldev running?)
web server (-server): localhost:2345 is already in use (is another ldev running?)
collector gRPC receiver: localhost:4998 is already in use (is another ldev running?)
collector HTTP receiver: localhost:4999 is already in use (is another ldev running?)
```

It's usually another instance of Localdev. To find what holds a port:

```sh theme={null}
lsof -nP -iTCP:50000 -sTCP:LISTEN
```

### Two instances at once

To run two at once, give the second one its own ports. For example:

```sh theme={null}
ldev -server localhost:2355 -collector-address localhost:50010 Projectfile
```

with, in its Projectfile:

```yaml theme={null}
collector:
    receivers:
        grpc: 5998
        http: 5999
```

The services' own ports (`API_PORT` and so on) must differ too.

## Start-up output

```
    localdev v0.1.0

	Web server:     http://localhost:2345
	MCP server:     http://localhost:2345/mcp
	Service output: /var/folders/…/T/localdev3584130741
```

`Service output` is the directory with the services' stdout and stderr files.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.