# How to deploy a Gradio app.

URL: https://antideploy.com/blog/how-to-deploy-a-gradio-app

Gradio deploys with one sentence. Your code must launch on 0.0.0.0 and the PORT variable, and the app has 1 GB of memory.

## At a glance

- **Entry file found**: app.py, main.py and more
- **python app.py**: Antideploy runs your file
- **Launch on PORT**: Set server_name and server_port
- **1 GB of memory**: Use hosted models where you can

Published 7 October 2026. Facts checked 7 October 2026. 3 min read.

## The short answer

To deploy a Gradio app, give your coding agent the sentence below. Antideploy finds Gradio in your requirements, finds the file that imports it, and runs it with `python`. Unlike Streamlit, Gradio is not started with extra flags, so your code must launch on `0.0.0.0` and on the port in the `PORT` variable. Each app has 1 GB of memory.

> **Say this to your coding agent**
>
> Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.

## What Antideploy detects

- **Gradio.** Detected from `gradio` in `requirements.txt` or `pyproject.toml`.
- **The entry file.** It looks for `streamlit_app.py`, `app.py`, `dashboard.py`, `main.py` and `home.py`, in that order, in the folder of your requirements. The first one that contains `import gradio` wins. Otherwise it uses any `.py` file that imports Gradio.
- **The start command.** `python <entry file>`. Nothing is added, so the launch settings are yours.
- **The port.** Antideploy sets `PORT` and sends traffic to it.

## The launch line

By default Gradio listens on `127.0.0.1`, which only your own computer can reach. On a server it must listen on `0.0.0.0` and on the port Antideploy gives it.

**app.py**

```
import os
import gradio as gr

def greet(name):
    return "Hello " + name

demo = gr.Interface(fn=greet, inputs="text", outputs="text")

demo.launch(
    server_name="0.0.0.0",
    server_port=int(os.environ.get("PORT", 7860)),
)
```

If your app uses `gr.Blocks`, the same `launch` call applies. Without these two arguments the deploy builds but never starts listening, and fails with a message that names the port.

## Memory

An app that loads a large model into memory when it starts can run out of 1 GB and be stopped before it listens. Two ways help.

- Call a hosted model instead of loading weights, for example through an [AI key](https://antideploy.com/blog/how-to-add-ai-to-your-app) that your agent creates
- If you must load a model, load it the first time it is needed, not at import time
- Pin Python to 3.12 in a `.python-version` file if a package such as `torch` has no build for a newer version

## Step by step

### 1. Add the launch arguments

Set `server_name="0.0.0.0"` and read the port from `PORT`.

### 2. Paste the sentence and approve one link

Your agent creates the app and deploys it. Keys you need, such as a model key, are saved as write-only variables.

### 3. Open your link

Antideploy installs your requirements, runs your file, and checks that the app answers. Your agent tells you the address.

## Here's where it stops.

A platform that only tells you what it is good at is one you find the edges of in production. These are the ones to know before your first deploy.

### Apps sleep when idle

On every plan, an app nobody is using goes to sleep and the next visit wakes it. The first request took 2.9 to 13.9 seconds in our measurements, depending on the stack. There are no always-on workers, so use a cron job or a webhook for background work.

### One instance, no previews

Each app is one instance with 1 shared vCPU and 1 GB of memory, and a Java app gets 1 dedicated vCPU and 2 GB. There are no preview deployments and no per-branch URLs.

### The disk forgets

Anything written to local disk is gone on the next deploy. Apps that speak S3 get a bucket instead.

## Gradio questions, answered.

Anything else? Write to us and a person answers.

[support@antideploy.com](mailto:support@antideploy.com)

### Is Gradio free to host here?

It runs on the Free plan, which includes 1 live app with a server. Failed deploys are free.

### Why does my Gradio app build but not start?

Usually it listens on `127.0.0.1` or on a fixed port. Set `server_name` and `server_port` as shown above. See [never started listening](https://antideploy.com/blog/your-app-built-successfully-but-never-started-listening-on-its-port).

### Can I run a local machine learning model?

Only if it fits in 1 GB together with the rest of the app. Large models usually do not. Use a hosted model instead.

### Does Gradio work with WebSockets and streaming?

Yes. Each app is one long-running process, and Antideploy sets no time limit of its own on a connection.

### Where do I put my API keys?

In environment variables. Values you save on Antideploy are encrypted and write-only.

## More guides, and the platform.

Each platform page covers one part of Antideploy: what it does, where it stops and the questions people ask. [See the whole platform](https://antideploy.com/platform), or [all the guides](https://antideploy.com/blog).

- [How to deploy a Streamlit app](https://antideploy.com/blog/how-to-deploy-a-streamlit-app): Your entry file is found, Streamlit starts with the right flags, and WebSockets stay open.
- [How to add AI to your app](https://antideploy.com/blog/how-to-add-ai-to-your-app): One key for hundreds of models, paid from a prepaid wallet in rupees. Your agent creates the key.
- [Your app built successfully but never started listening on its port](https://antideploy.com/blog/your-app-built-successfully-but-never-started-listening-on-its-port): The app built but never answered on its port. Read PORT, listen on 0.0.0.0 and check the logs.

- [Hosting](https://antideploy.com/platform/hosting)
- [AI models](https://antideploy.com/platform/ai-models)
- [Environment variables](https://antideploy.com/platform/environment-variables)
- [Deployments](https://antideploy.com/platform/deployments)

Facts on this page were checked against the live platform on 7 October 2026.

## Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

To set this up, give your coding agent this sentence:

```text
Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.
```
