Skip to content
zefıly

How to host a Python app on your own server

Zefily runs Python 3.12, 3.13 or 3.14 with uv, and starts your app with gunicorn as a managed service. This guide covers a Flask or Django app, and what the Python preset needs from your project.

Before you start

  • A server connected to Zefily with the web stack installed.
  • A Python project in Git with pyproject.toml and uv.lock committed.
  • The WSGI module of your app: a Flask app object, or the wsgi module of a Django project.

Steps

  1. 1. Install Python

    In the server's web stack click Install Python and pick 3.12, 3.13 or 3.14. Choose the version your dependencies support.

  2. 2. Add the site

    Choose Sites, then Add site. Select Runs on: Python, the version and the domain. Zefily assigns a free local port.

  3. 3. Add gunicorn to the project

    Run uv add gunicorn on your computer and commit pyproject.toml and uv.lock. The start command runs gunicorn, so it must be a dependency of the project.

  4. 4. Set the Git deploy with the Python preset

    On the Deploy pane choose the Python preset and your repository. The build command is uv sync --frozen --no-dev and the start command is uv run gunicorn --bind 127.0.0.1:$PORT app:app. Replace app:app with your WSGI callable: app:app for a Flask object named app in app.py, or mysite.wsgi:application for a Django project called mysite.

  5. 5. Check the lock file

    The preset runs uv sync --frozen only when a uv.lock exists; without one it runs uv sync --no-dev. A project with only requirements.txt is not installed by the preset, so write your own install command there.

  6. 6. Add the configuration and database

    Put settings in the site's .env and set DEBUG off in production. Connect a database to fill in DATABASE_URL.

  7. 7. Run workers as daemons

    Task queues and schedulers run as daemons of the site user, with the working folder in the live current folder of the site.

  8. 8. Deploy and check

    Click Deploy now. The app restarts on the new release. If it does not start, the site switches back to the previous release.

Verify it works

Open the domain: the app answers over HTTPS. The App process output on the Logs pane shows gunicorn listening on 127.0.0.1, and a page you know returns the response you expect.

Troubleshooting

gunicorn: command not found
The project does not list gunicorn as a dependency. Run uv add gunicorn, commit the updated uv.lock and deploy.
The app fails to import
The app:app part does not match your code. Use the module path and the object name your app uses; for Django, use the wsgi module of the project.
Nothing installs on deploy
The project has only requirements.txt, which the preset skips. Add a pyproject.toml managed with uv, or set your own install command on the Deploy pane.

Questions

Can I run FastAPI?

Yes. Use an ASGI command instead, for example uv run uvicorn main:app --host 127.0.0.1 --port $PORT --workers $WEB_CONCURRENCY.

Which Python version should I choose?

Python 3.12, 3.13 and 3.14 are available. Choose the newest one that all your dependencies support.

Can my app use a database?

Yes. Connect MariaDB or PostgreSQL from the Databases pane; Zefily fills in DATABASE_URL for the app.

Read next

Start on a server you own

Create your account, connect a server and follow the guide. The server stays yours: you pay your provider.

Start free

Black Friday & Cyber Monday

Before you go: lifetime plans are on sale

Pay once for a lifetime plan, or get 30% off the first year of any yearly plan.

Only 100 lifetime plans per plan. When they are gone, they are gone.

See the campaign

Amazing November

See the campaign →