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

# Run Airflow locally in VS Code

> Use the Local view in Astro for VS Code to start and stop local Airflow in standalone or Docker mode, read component logs, see import errors and failed runs, and use the project's Python environment.

<Info>
  **Labs**

  This feature is in [Labs](/docs/astro/feature-previews).
</Info>

The **Local** view in Astro for VS Code shows the Astro projects open in your window and their local Airflow environments. From the view, you can start and stop Airflow in [standalone or Docker mode](/docs/cli/v1.46/local-airflow-overview), read each component's logs, see Dags that fail to import and Dag runs that failed, and point your editor's Python extension at the project's environment.

The view runs the Astro CLI's `astro dev` commands, so a project you start in the view is the same one that `astro dev ps` reports in a terminal, and the other way around.

## Prerequisites

* Astro for VS Code. See [Get started with Astro for VS Code](/docs/astro/vscode/vscode-quickstart).
* An Astro project open in your window. An Astro project is a folder that contains `.astro/config.yaml`. To create one, run [`astro dev init`](/docs/cli/v1.46/astro-dev-init).
* For Docker mode, a running container runtime, such as Docker Desktop.

The view finds a project only when the project folder is one of the folders open in the window. It doesn't search subfolders. To work on several projects, add each one with **File** > **Add Folder to Workspace**.

## Read a project's status

Each project row shows the project name and its state:

* **running on `<port>`**, with **Docker mode** when it runs in Docker
* **stopped**
* **starting…** or **stopping…** while a command runs

A project on Airflow 2 also shows its Airflow version. Hover over a row to see the project's details, including the Airflow version, Astro Runtime image, Python interpreter, and Airflow UI address.

## Start Airflow

Hover over a stopped project and click one of the following options, or right-click the project:

* **Start Local Airflow (Standalone)** (play icon): Runs `astro dev start --standalone`. Airflow runs as local processes, without containers.
* **Start Local Airflow (Docker)** (whale icon): Runs `astro dev start --docker`.

The command runs in a terminal, so you can watch its progress. The first standalone start creates a virtual environment and installs Airflow, which can take a few minutes. See [`astro dev start`](/docs/cli/v1.46/astro-dev-start).

## Stop or kill Airflow

To stop a running project, hover over it and click the stop icon, or right-click it and choose **Stop Local Airflow**. Stopping keeps the project's local metadata database and logs, so the next start continues where the project left off.

To remove the local environment, right-click the project and choose **Kill Local Airflow and Delete Its Data**, then confirm.

<Warning>
  Killing a local Airflow environment deletes its metadata database and logs. You lose the Dag runs, connections, and variables you created in the local Airflow UI.
</Warning>

Both actions use the mode the project runs in, or the mode you last started it in. See [`astro dev stop`](/docs/cli/v1.46/astro-dev-stop) and [`astro dev kill`](/docs/cli/v1.46/astro-dev-kill).

## Open the Airflow UI

Hover over a running project and click the Airflow icon, or right-click it and choose **Open Local Airflow UI**.

## See import errors and failed runs

Expand a running project to see the following groups:

* **Import errors (N)**: Dag files that Airflow can't import. Click one to open the file at the line that failed.
* **Failed runs (N) · last 1d**: Dag runs that failed in the last 24 hours. Click one to open its task logs in an editor tab.

Each item also offers the Otto icon to ask Otto about it, and **Show Import Error Traceback** or **Show Failure Logs**. See [Ask Otto about a failure](/docs/astro/vscode/vscode-otto-chat#ask-otto-about-a-failure).

## Read component logs

Expand **Logs (N)** under a project and click a row to open that log in a read-only editor tab.

<Tabs>
  <Tab title="Standalone mode">
    * **All components**: The full standalone log. Each line shows the component that wrote it.
    * One row for each component, such as **scheduler**, **api-server**, **triggerer**, and **dag-processor**.
    * **Dag parsing**: The Dag processor's log for each Dag file.

    The extension reads these logs from the project's `.astro/standalone/` folder. A long log opens at its most recent part.
  </Tab>

  <Tab title="Docker mode">
    * **All components**: The logs of every container. Lines don't show which container wrote them.
    * One row for each container.

    The extension reads these logs with [`astro dev logs`](/docs/cli/v1.46/astro-dev-logs), so they're available only while the project is running.
  </Tab>
</Tabs>

## Use the project's Python environment

When you start a project in standalone mode, the Astro CLI creates a virtual environment in the project's `.venv` folder and installs Airflow in it. To resolve imports such as `from airflow.sdk import …` in your editor, right-click the project and choose **Use This Project's Airflow Environment for Python**.

This command sets the Python interpreter for the project folder with Microsoft's Python extension. If the Python extension isn't installed, or the project doesn't have a `.venv` folder yet, the extension tells you what to do.

## Upgrade to Airflow 3

A project on Airflow 2 shows its Airflow version and when its support ends. To start an upgrade with Otto, expand the project and click **Upgrade to Airflow 3.x.y**, or right-click the project and choose **Upgrade to Airflow 3 with Otto**.

For a local project, the extension also tells Otto whether the project's Python version must change for the new Astro Runtime image, and whether the project is running and in which mode. Otto also checks `requirements.txt` for outdated providers. Otto verifies the upgrade by restarting the project in the same mode.

After the project's `Dockerfile` names an Airflow 3 image, the row no longer offers the upgrade. For more about upgrades, see [Upgrade to Airflow 3](/docs/astro/vscode/vscode-deployments#upgrade-to-airflow-3).

## Other projects

**Other projects (N)** lists local Airflow environments that the Astro CLI runs from folders that aren't open in the window. You can open their Airflow UI, but you can't start or stop them from the view.

If a project's folder was deleted without stopping Airflow first, its row shows **its project folder is gone**. Find the process ID in the row's tooltip, then stop the process from a terminal.

## Next steps

* [Local Airflow overview](/docs/cli/v1.46/local-airflow-overview)
* [Chat with Otto in VS Code](/docs/astro/vscode/vscode-otto-chat)
