# Run the dev network

> Run a whole Minekube network on your machine - a relay where players join, a Velocity proxy with the Minekube plugin, two labeled Paper servers and a local Minekube API - and install your proxy bundle on every save.

A proxy bundle needs a network to run in. The dev network is a complete one on your own machine: the same relay, proxy, servers and Minekube API as in production, on loopback ports. You program its proxy and play on it like on the dev server.

> **Preview:**
> The dev network runs from a [Minekube checkout](https://github.com/minekube/minekube) only, for now. The CLI release does not include `mk server --network`, `mk relay` and `mk api` yet.

## Start the network

```sh
mk server --network --accept-eula
```

The dev network runs beside the dev server, on its own ports, and listens on `127.0.0.1` only:

| Part | Address | What it does |
| --- | --- | --- |
| Relay | `localhost:25577` | Where players join. Passes them over [iroh](https://iroh.computer) to the proxy. |
| Velocity | `127.0.0.1:25578` | The proxy, with the Minekube plugin. Offline mode, modern forwarding. Runs in the foreground. |
| `lobby` | `127.0.0.1:25580`, RCON 25590 | A Paper server labeled `stage=lobby`. Players land here. |
| `arena` | `127.0.0.1:25581`, RCON 25591 | A Paper server labeled `game=arena`. |
| Minekube API | `http://localhost:4776` | Its registry knows every instance and its labels. Velocity finds `lobby` and `arena` [by their labels](https://minekube.com/guide/networks/labels) through it. |
| Devtools | `http://127.0.0.1:4774` | The proxy's and the servers' sessions. |

Both Paper servers run the Minekube plugin, plus ViaVersion and ViaBackwards, so clients older than the servers can play too. They accept players only through the proxy. Stopping Velocity (`end`, or Ctrl-C) stops the whole network.

## Install your proxy bundle

In the project:

```sh
mk dev .
```

`mk dev` builds the project's `velocity` bundle (`proxy/velocity.ts` in a project from `mk init`) into the proxy's `plugins/minekube/bundles/<name>.js` and reinstalls it on every save. A project with a `paper` bundle also gets its game installed on the dev server.

## Join the network

Join `localhost:25577` with Minecraft. You land on `lobby`; Velocity's `/server arena` moves you, and `/lobby` brings you back. When you save, players see `[proxy] Reloaded <id> (<revision>)` in chat, and nobody disconnects. On the dev proxy every player counts as a developer and sees these messages; the [runtime messages](https://minekube.com/games/reference/runtime-messages) are those of a game, in the proxy's log.

## Related

- [Proxy bundles](https://minekube.com/games/write/proxy-bundles): write the rules and the proxy half.
- [Labels and selectors](https://minekube.com/guide/networks/labels): how the proxy finds `lobby` and `arena`.
- [Connector, relay and API](https://minekube.com/guide/networks/connectivity): what the relay and the Minekube API do.
