Deploying FastAPI Projects

Deploy FastAPI applications on Skyversal with Uvicorn ASGI server. Auto-detection, CORS setup, and environment variables.

Deploying FastAPI Projects

With Pydantic-powered validation, modern design, and blazing speed, FastAPI is becoming the standard for next-generation REST APIs. Skyversal instantly deploys your FastAPI projects with the asynchronous (ASGI) Uvicorn server.

Read Time: 4 Minutes
Server: Uvicorn
Standard: ASGI

What you'll learn in this guide

  • Required dependencies (Uvicorn requirement)
  • FastAPI app object detection logic
  • Environment variables
  • CORS and production settings

1. Required Dependencies (requirements.txt)

FastAPI applications need the uvicorn server to run at high performance (asynchronously) in production. Make sure your dependency file includes these two packages:

requirements.txt
fastapi==0.110.0
uvicorn==0.27.1 # Required as ASGI server
# ... your other dependencies

2. How Is the FastAPI App Detected?

When Skyversal detects the fastapi package in your dependencies, it automatically starts your project with Uvicorn.

Skyversal searches for the app = FastAPI() object in these files, in order:

  • main.py (Standard FastAPI convention)
  • app.py
  • api.py
💡
Changing the Entry Point (FASTAPI_APP)

If your application is inside a folder or has a different name (e.g., src/server.py), go to the Skyversal panel and add a new variable under Settings > Environment Variables:

Key: FASTAPI_APP
Value: src.server:app

3. CORS and Environment Variables

If you're building an API with FastAPI, you'll typically communicate with a frontend (React, Vue, etc.). You can securely configure CORS permissions using URLs entered through the Skyversal panel:

from
fastapi
import
FastAPI
from
fastapi.middleware.cors
import
CORSMiddleware
import
os

app = FastAPI()

# Reading the frontend URL from the panel
FRONTEND_URL = os.getenv('FRONTEND_URL', '*')

app.add_middleware(
    CORSMiddleware,
    allow_origins=[FRONTEND_URL],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

@app.get('/')
async def
root():
    
return
{"message": "FastAPI Running on Skyversal 🚀"}

Common Errors (Troubleshooting)

Application failed health check

Fix: Uvicorn can't find the app object. Make sure your file is named main.py or app.py, or that you've correctly set the FASTAPI_APP variable.

ModuleNotFoundError: No module named 'fastapi'

Fix: Your GitHub repo is missing requirements.txt or it's in the wrong directory.

Port In Use (EADDRINUSE)

Fix: If you have uvicorn.run(app, port=8000) at the bottom of your code, you can remove it; Skyversal handles port management automatically via Uvicorn.

You're Ready! 🚀

After adding the required packages, push your code. Skyversal will have your FastAPI project up and running via Uvicorn in seconds.

Last updated on July 29, 2026
Edit this page on GitHub