# Starting applications

You start every application of a project with mp run-local in the root of its repository, and the command works the same locally on your machine and in the remote workspace.

> Source: https://www.mainpath.ai/en/docs/workspace-ubuntu-dev-scripts/

You start every repository with the same command in its folder:

```bash
mp run-local
```

The `ap` CLI loads the [environment files]({{< relref "environment-setup" >}}) from `env/`, starts the services, and then the development server; the command behaves the same locally and in the [remote workspace]({{< relref "workspaces-overview" >}}), and the start button of MainPath extension in VS Code, Cursor, and Antigravity runs it in a terminal.

## Backend, app, and homepage

A backend needs Docker running: `mp run-local` uses Docker Compose to start the database, Mailhog for caught emails, and PHPMyAdmin, then the development server of NestJS, FastAPI, or Laravel. An app starts as Flutter web or with the development server of its stack such as Next.js or Expo, with the generated and custom environment files in the build (for Flutter via `--dart-define-from-file`); you specify target and device like this:

```bash
mp run-local chrome            # web build in the browser
mp run-local ios-simulator     # iOS simulator, macOS only
mp devices list                # show available devices
```

A homepage starts Hugo or Astro on the port of the repository. The runtimes come from `.tool-versions`, via `asdf` on macOS and Linux and via FVM, NVM, and HVM on Windows; `mp bootstrap` installs them without starting the application, and `mp doctor` checks whether all tools are present.

## Ports

Every repository has fixed local ports from MainPath, so backend, app, and homepage run in parallel:

```bash
mp ports
```

The command shows which port belongs to which repository.

## Stopping

The development server runs in the terminal until you stop it with Ctrl+C; the Docker containers of a backend can keep running, and you see and stop them in Docker Desktop or with `docker ps`.

## When something does not start

If `mp doctor` reports a missing tool, install it through the developer setup of the [MainPath Toolbox]({{< relref "local-app" >}}); in the workspace, the tools are preinstalled. If a port is taken, an earlier instance of the same application or an old container is usually still running, so stop it; `mp ports` tells you which port is meant. If a backend fails on its services, Docker is usually not running; start Docker Desktop and repeat the command. Add your own variables to `env/local.custom.env` and restart; MainPath overwrites the generated files in `env/`.

