Skip to content
By stack4 min read

FastAPI hosting for APIs and AI backends

Short answer

FastAPI is an ASGI framework, while Passenger runs Python apps over WSGI. So on ArabyHost's AI/Developer plans, FastAPI runs once it's wrapped in an adapter such as a2wsgi inside passenger_wsgi.py. That suits regular REST APIs; WebSockets and streamed responses need another approach.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. What FastAPI needs in production
  2. How FastAPI runs on ArabyHost
  3. What works directly and what needs another approach
  4. Which plan fits FastAPI?
  5. Limits to know up front
  6. On ArabyHost

FastAPI is one of the most used Python frameworks for building APIs today, especially for AI apps that call language models and return JSON. It’s built on ASGI and usually served by Uvicorn. On hosting that runs Phusion Passenger, the app goes through a small adapter that turns it into a WSGI app. That covers most REST APIs, with clear limits explained below.

What FastAPI needs in production

  • A current Python: recent FastAPI and Pydantic 2 releases run on Python 3.9 and newer; 3.12 is the best choice.
  • An application server: Uvicorn or another ASGI server, or an adapter to WSGI when the available server is WSGI.
  • A virtual environment: with fastapi, pydantic and your project’s packages.
  • A database: SQLAlchemy or SQLModel with MySQL/MariaDB, or SQLite for a small API.
  • Environment variables: for model API keys and database credentials.
  • HTTPS and CORS: if the front end lives on another domain, configure CORSMiddleware with only the domains you allow.

How FastAPI runs on ArabyHost

Passenger runs Python apps through passenger_wsgi.py and expects a WSGI object named application there. So the FastAPI app is wrapped with a2wsgi, a library that converts an ASGI app to WSGI:

source ~/virtualenv/api/3.12/bin/activate && cd ~/api
pip install fastapi a2wsgi
# passenger_wsgi.py
import os, sys
sys.path.insert(0, os.path.dirname(__file__))

from a2wsgi import ASGIMiddleware
from main import app

application = ASGIMiddleware(app)

Deployment in short:

  1. In cPanel, open Setup Python App, create an app with Python 3.12 and give it a subdomain such as api.example.com.
  2. Deploy the code from GitHub with Git Version Control, as a ZIP, or from Claude or Cursor through Araby MCP.
  3. Install the packages over SSH and write passenger_wsgi.py as above.
  4. Add environment variables, such as your model’s API key, on the app page, then click Restart.
  5. Open https://api.example.com/docs and try the endpoints.

The full walkthrough, with common errors and fixes, is in the FastAPI deployment guide.

What works directly and what needs another approach

Case Through the adapter on Passenger
JSON REST routes, Pydantic validation Works
async def endpoints calling external services with httpx Works
/docs and /redoc Work
OAuth2 and JWT authentication Works
WebSockets Don’t work
Streaming responses (SSE, StreamingResponse) May be buffered and arrive at once; test before relying on it
BackgroundTasks for long jobs Ties up the process longer; a background worker is better
lifespan startup events Test them after deploying, or move critical setup to module level

Long jobs and model calls

If a request waits a long time on a language model or processes a big file, don’t hold the connection open. Store the job in the database, return its ID to the client right away, and let a background worker run it. A cron job keeps that worker alive and restarts it if it stops; the client then polls for the result with the job ID.

Which plan fits FastAPI?

FastAPI needs an AI/Developer plan, the only plans with Python apps and SSH; shared, WordPress and WooCommerce plans run PHP only. AI plans also include Node.js 20 and 24 if your front end is built with React or Next.js, and Claude Code and Codex run on them over SSH. Size the plan by concurrent requests and memory use, since large libraries need more memory; the differences are on the pricing page.

Limits to know up front

  • No public ASGI server: you can’t open a port for Uvicorn that visitors reach; requests go through Passenger.
  • No WebSockets from Python: an app built around WebSockets or continuous streaming needs a server with wider access.
  • No GPU, no Docker, no root: call models through an API rather than running them locally, and install packages in the virtual environment.
  • Per-account resources: memory, CPU and process count depend on the plan.

If these limits block your project, read shared hosting vs VPS. ArabyHost doesn’t offer a VPS yet; it’s planned.

On ArabyHost

For a REST API, or the backend of an AI app that calls models through an API, choose an AI/Developer plan, create the app in Setup Python App with the adapter, and deploy from GitHub. You get free SSL issued automatically, the LiteSpeed web server, daily backups and CageFS isolation for your account. If the app stops, the Araby AI assistant reads the error log and explains why, and support is available in Arabic.

FAQ

Can FastAPI run on cPanel hosting?

Yes, if the plan supports Python apps. Wrap the app in an ASGI-to-WSGI adapter such as a2wsgi and Passenger runs it like any other Python app. On ArabyHost that means the AI/Developer plans.

Does the /docs page work after deployment?

Yes. Swagger UI and ReDoc are ordinary HTTP requests. If you deploy under a sub-path instead of its own domain you may need to set root_path, so a subdomain like api.example.com is simpler.

Can I run Uvicorn instead of the adapter?

You can't open a public port for visitors, so Uvicorn can't serve the site's traffic directly. Requests go through Passenger and the adapter; work that isn't tied to a request runs in a background worker kept alive by cron.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.