The uvicorn server process is failing to start because the necessary Python package, uvicorn, is not present in your current Python environment. This means FastAPI has no way to actually run and serve your application.

Here’s how to fix it, covering the most common scenarios:

1. Uvicorn is Not Installed at All

This is the most straightforward case. You simply need to install uvicorn into your Python environment.

Diagnosis: Try running uvicorn directly from your terminal:

uvicorn --version

If you get a "command not found" error, uvicorn is not installed or not in your PATH.

Fix: Install uvicorn using pip:

pip install uvicorn

This command downloads and installs the uvicorn package and its dependencies into your active Python environment.

Why it works: This makes the uvicorn executable available in your environment’s bin or Scripts directory, allowing you to run it as a command-line tool.

2. Uvicorn is Installed in a Different Python Environment

You might have multiple Python installations or virtual environments on your system. If uvicorn is installed in one environment, but you’re trying to run your FastAPI app from another, you’ll encounter this warning.

Diagnosis: Activate the virtual environment where you believe FastAPI is installed. Then, check for uvicorn:

# Example for venv
source venv/bin/activate
pip show uvicorn

If pip show uvicorn returns nothing, it’s not in this environment. Then, check your global Python installation or other virtual environments.

Fix: Activate the correct environment where uvicorn is installed, or install uvicorn into the environment you are currently using. If you need to install it into your current environment:

pip install uvicorn

If you found it in another environment, ensure you activate that environment before running your FastAPI application.

Why it works: Python and its packages are isolated by environment. Activating an environment tells your shell to use the Python interpreter and installed packages from that specific directory.

3. Using a Package Manager Other Than Pip (Less Common for Uvicorn, but Possible)

While pip is the standard, some users might use conda or other package managers.

Diagnosis: If you’re using conda, try:

conda list uvicorn

If it’s not found, it’s not installed via conda.

Fix: If using conda, install uvicorn:

conda install -c conda-forge uvicorn

The -c conda-forge flag tells conda to look for the package in the conda-forge channel, which is a common source for many packages.

Why it works: Conda manages packages and environments differently than pip. This command ensures uvicorn is installed and discoverable within your conda environment.

4. Uvicorn is Installed, but Not in Your PATH

Sometimes, uvicorn might be installed, but the directory containing its executable (uvicorn command) isn’t in your system’s PATH environment variable.

Diagnosis: After running pip install uvicorn, check your Python site-packages directory for an uvicorn script. The location depends on your OS and Python installation. For example, in a venv on Linux/macOS, it might be in venv/bin/.

Fix: Add the directory containing the uvicorn executable to your system’s PATH. This is OS-dependent.

  • Linux/macOS: Edit your shell’s profile file (e.g., ~/.bashrc, ~/.zshrc) and add:

    export PATH="$PATH:/path/to/your/python/bin"
    

    Replace /path/to/your/python/bin with the actual path to the directory containing the uvicorn script. Then, reload your shell: source ~/.bashrc (or your respective file).

  • Windows: Search for "Edit the system environment variables," click "Environment Variables," select "Path" under "User variables" or "System variables," click "Edit," and add the full path to the directory containing uvicorn.exe.

Why it works: The PATH environment variable tells your operating system where to look for executable commands. By adding the correct directory, you make the uvicorn command discoverable system-wide or for your user.

5. Running FastAPI via python -m uvicorn

This is a common workaround or alternative way to run uvicorn, especially if you’re having trouble with the uvicorn command itself being in the PATH.

Diagnosis: You’ve confirmed uvicorn is installed via pip show uvicorn, but uvicorn --version still fails.

Fix: Instead of running uvicorn main:app, run it as a module:

python -m uvicorn main:app --reload

Replace main:app with your actual application’s module and FastAPI instance.

Why it works: The python -m <module> syntax tells Python to run a specific module as a script. This bypasses the need for the uvicorn executable to be directly in your system’s PATH, as it uses the uvicorn module found within your Python environment.

6. Corrupted Uvicorn Installation

Rarely, the uvicorn installation itself might be corrupted.

Diagnosis: If you’ve tried reinstalling and still face issues, or if pip show uvicorn shows it but it behaves erratically.

Fix: Uninstall and then reinstall uvicorn:

pip uninstall uvicorn
pip install uvicorn

This ensures you have a clean, fresh copy of the package.

Why it works: This process removes all files associated with the previous uvicorn installation and then downloads and installs a new, uncorrupted version.

Once uvicorn is correctly installed and accessible, you should see output like this when starting your app:

INFO:     Will watch for changes in these directories: ['/path/to/your/project']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [12345] using statreload
INFO:     Started server process [12346]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

The next error you’ll likely encounter if your FastAPI code is malformed is a ModuleNotFoundError for a dependency you forgot to install.

Want structured learning?

Take the full Fastapi course →