# How to deploy an app you built with AI

Push the code to GitHub, connect the repository once, add the app's variables and press Deploy. Every push after that deploys by itself.

Source: https://hostsrc.com/guides/deploy-ai-built-app. Last checked 2026-12-01, the day someone last followed the steps.

To put an app you built with an AI assistant online, push its code to GitHub, connect the repository in the control panel, add its variables and press **Deploy**. We detect the language and build it. Every push after that deploys by itself.

Code an assistant writes is ordinary code, so it runs like any other app. A few things that work on your computer need a change first: the port, the secrets and the data. Step 1 covers them.

> **On Hostsrc:** App hosting is in beta. [Order Hobby or Pro](/app-hosting#pricing) and **Apps** shows in the panel once your payment is confirmed. Final price, no VAT added.

## Before you start

- A Hostsrc account with App hosting turned on. It's in beta, so [order Hobby or Pro](/app-hosting#pricing) first.
- The app's code on your computer, in a Git repository.
- A GitHub account.

## Steps

### Step 1: Get the app ready to run on a server

Link to this step: https://hostsrc.com/guides/deploy-ai-built-app#step-1

Check three things, or ask your assistant to check them:

- **The port.** A web app must listen on `0.0.0.0` and on the port in the `PORT` variable, not on a fixed port on `localhost`. We set `PORT` for every web service. It is `8080` unless you change it.
- **The secrets.** API keys and passwords must come from variables, not from the code. Keep them in a `.env` file that Git ignores, and list their names in a `.env.example` file.
- **The data.** Each deploy starts from a fresh build of your code. Keep data you need in a database (step 6), not in a file in the app's folder.

You can paste this to your assistant:

```text
Make this app ready to deploy: listen on 0.0.0.0 and on the port in the PORT environment variable, read every secret from environment variables, list their names in .env.example, and make sure .env is in .gitignore.
```

> **Warning:** Never push a `.env` file with real keys. If one was pushed, change those keys, because anyone who can see the repository can read them.

### Step 2: Push the code to GitHub

Link to this step: https://hostsrc.com/guides/deploy-ai-built-app#step-2

Create a repository on [GitHub](https://github.com/new), private or public, and push the code to it. If your assistant works in a terminal, it can run these commands for you. Use your own repository's address in the fifth line.

```text
git init
git add .
git commit -m "First version"
git branch -M main
git remote add origin https://github.com/you/your-app.git
git push -u origin main
```

### Step 3: Connect the repository

Link to this step: https://hostsrc.com/guides/deploy-ai-built-app#step-3

Sign in at [control.hostsrc.com](https://control.hostsrc.com) with your Hostsrc account. In the header, switch to **Apps**.

On **Projects**, press **New**, then **Connect GitHub**, and choose **GitHub**. GitHub asks which repositories to share: allow your app's repository. Back in Apps, press **New** again, choose **GitHub Repository** and pick it.

The panel makes a project named after the repository, with the app in it as a service. The service opens on **Variables**. Nothing runs until you press **Deploy** in the next step.

### Step 4: Add the variables and deploy

Link to this step: https://hostsrc.com/guides/deploy-ai-built-app#step-4

Copy each name and value from your `.env` file. On **Variables**, open **Raw editor** and paste them, one `NAME=value` per line. Or press **New variable** for each one. If the repository has a `.env.example` file, the panel lists its names under **Suggested variables**.

Press **Save variables**, then **Deploy**. Saving alone doesn't start the app.

```text
OPENAI_API_KEY=paste-your-key-here
SESSION_SECRET=a-long-random-string
```

> **Note:** You don't add `PORT`. We set it for you.

### Step 5: Give the app a web address

Link to this step: https://hostsrc.com/guides/deploy-ai-built-app#step-5

A website or an API needs an address. Open **Settings**, then **Networking**. Under **Public networking**, press **Generate Domain**. The port is filled in from the one your app listens on. Check it, then press **Generate**.

The app gets an address on `up.hostsrc.app`, such as `your-app-production.up.hostsrc.app`.

To use your own domain, press **Custom Domain**, type the domain and press **Add domain**. The panel shows the DNS record to add at your domain's provider. Add it, then press **Check now**. The domain shows **Live** once HTTPS is set up.

> **Note:** A bot or a background worker needs no address. It shows **Private service**, and that is right.

### Step 6: Add a database if the app needs one

Link to this step: https://hostsrc.com/guides/deploy-ai-built-app#step-6

On the project, press **New**, then **Database**, and choose **PostgreSQL**. It shows up as a service named **Postgres**.

Open your app's **Variables** and add `DATABASE_URL` with the value below. Typing `${{` in a value lists what you can use. Press **Save variables**, then **Deploy**.

```text
DATABASE_URL=${{Postgres.DATABASE_URL}}
```

> **Note:** If your code reads another name, keep the value and change the name on the left. The database's **Connect** tab shows the reference too, under **From another service**.

### Step 7: Push changes and watch them go live

Link to this step: https://hostsrc.com/guides/deploy-ai-built-app#step-7

From now on, every push to the repository's branch builds and deploys by itself. Open **Deployments** to watch it. A deployment shows **BUILDING** while we build the code and **ACTIVE** once the app runs. **View logs** shows the build step by step, and **Logs** shows what the app prints.

If a change breaks something, open **History** on **Deployments** and open an earlier deployment. Choose **Rollback to this** in its menu and confirm with **Roll back**.

## Troubleshooting

### The deploy fails because the app is not ready

The app didn't answer on its port. Make it listen on `0.0.0.0` and on the port in `PORT`, then push again. If the panel says it listens on localhost only, change the host to `0.0.0.0`. Many development servers take a `--host` option for this.

### The build fails

Open the failed deployment and read its build logs. The last lines name the problem.

If the build can't tell how to start the app, set **Start command** in **Settings**, under **Deploy**, for example `npm start` or `python main.py`. Then press **Deploy**. If the repository has a `Dockerfile` in its top folder, we build from it instead.

### The app works on my computer but not here

Open **Logs** and read the last lines. Two causes are common:

- A variable is missing. Compare the names in your `.env` file with the ones on **Variables**.
- The app still points at `localhost` for another service, such as a database. Use the reference from step 6 instead.

### My repository isn't in the list

GitHub only shares the repositories you allowed. In the repository list, choose **Configure repository access**, allow the repository on GitHub, then come back and press **New** again.

## Related guides

- [How to deploy a Next.js app from GitHub](https://hostsrc.com/guides/deploy-nextjs-app-from-github)
- [How to host a discord.py bot](https://hostsrc.com/guides/host-discord-py-bot)
- [How to put a Discord bot online with App hosting](https://hostsrc.com/guides/discord-bot-app-hosting)

## Links

- [GitHub](https://github.com/new): create the repository for your app
- [Hostsrc control panel](https://control.hostsrc.com): sign in, then switch to Apps
- [App hosting](https://hostsrc.com/app-hosting): plans and prices, with a link to order each plan
