Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

425
Views
How can I fix FastAPI application error on Apache WSGI?

I am trying to run FastAPI application on Apache running server.

I have configured Apache virtual host file accordingly
<VirtualHost *:80>
        ServerAdmin admin@example.com
        ServerName fastapi.example.com
        ServerAlias fastapi.example.com
        DocumentRoot /var/www/fastapi
        ErrorLog ${APACHE_LOG_DIR}/fastapi_error.log
        CustomLog ${APACHE_LOG_DIR}/fastapi_access.log combined
        WSGIScriptAlias / /var/www/fastapi/main.wsgi
        <Directory "/var/www/fastapi">
                AllowOverride All
        </Directory>
</VirtualHost>

and created main.wsgi and main.py files.

main.wsgi

#! /usr/bin/python3.7

import logging
import sys
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, '/var/www/fastapi/')
from main import app as application
application.secret_key = 'alibaba'

main.py

from typing import Optional
from fastapi import FastAPI
app = FastAPI()

@app.get("/")
def read_root():
    return {"Hello": "World"}

@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
    return {"item_id": item_id, "q": q}

When i am trying to access the web, I got the 500 Internal server Error with the following log in fastapi_access.log

mod_wsgi (pid=24946): Exception occurred processing WSGI script '/var/www/fastapi/main.wsgi'.
TypeError: __call__() missing 1 required positional argument: 'send'

Could you please advice, how can I fix this problem and what am I doing wrong?

Thanks in advance.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

WSGI servers is not compatible with FastAPI, FastAPI only runs in ASGI server, gunicorn and all the other WSGI servers just implements PEP Standards with ASGI workers in depth they still work as ASGI with the workers.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!