# How to Configure ReClip Port and Host: Environment Variable Guide

> Learn how to configure ReClip port and host using environment variables. Discover default settings for ReClip's PORT and HOST variables to customize your ReClip setup.

- Repository: [Avery Gan/reclip](https://github.com/averygan/reclip)
- Tags: how-to-guide
- Published: 2026-09-05

---

**ReClip determines its listening port and host through environment variables `PORT` and `HOST`, falling back to `8899` and `127.0.0.1` respectively when these variables are unset.**

Learning how to configure ReClip port and host settings is essential when deploying the averygan/reclip repository across different environments. The application uses standard environment variable patterns in [`app.py`](https://github.com/averygan/reclip/blob/main/app.py) to control network binding, allowing flexible deployment on localhost, private networks, or Docker containers without modifying source code.

## Where ReClip Reads Port and Host Settings

The Flask server initialization retrieves network configuration directly from environment variables using Python’s `os.environ.get()` method. According to the source code in [`app.py`](https://github.com/averygan/reclip/blob/main/app.py) at lines 108-110, the application explicitly defines fallback values:

```python
port = int(os.environ.get("PORT", 8899))
host = os.environ.get("HOST", "127.0.0.1")
app.run(host=host, port=port, debug=True)

```

This implementation means ReClip automatically uses port `8899` and binds to localhost (`127.0.0.1`) unless you override these values through environment variables.

## Three Methods to Configure ReClip Port and Host

### Method 1: Export Environment Variables (Local Execution)

For direct execution using [`reclip.sh`](https://github.com/averygan/reclip/blob/main/reclip.sh) or running [`app.py`](https://github.com/averygan/reclip/blob/main/app.py) manually, export the variables in your shell session before launching:

```bash
export PORT=8080
export HOST=0.0.0.0
./reclip.sh

```

The startup script [`reclip.sh`](https://github.com/averygan/reclip/blob/main/reclip.sh) (lines 50-52) checks for existing `PORT` values using `${PORT:-8899}` syntax, preserving your export if set, but does not provide a default `HOST` value. This means you must explicitly export `HOST` when requiring non-localhost binding.

### Method 2: Docker Compose with .env Files

When using Docker Compose, create a `.env` file in the project root directory:

```dotenv
PORT=8080
HOST=0.0.0.0

```

The [`docker-compose.yml`](https://github.com/averygan/reclip/blob/main/docker-compose.yml) references these variables using `${PORT}` syntax for port mapping configuration. Start the container with:

```bash
docker-compose up --build

```

Docker Compose automatically reads the `.env` file and substitutes values into the compose configuration, updating both the internal application port and the external mapping.

### Method 3: Docker Run Commands

For standalone Docker containers without Compose, pass environment variables using the `-e` flag:

```bash
docker run -d \
  -e PORT=8000 \
  -e HOST=0.0.0.0 \
  -p 8000:8000 \
  --name reclip averygan/reclip:latest

```

This approach explicitly sets the runtime configuration without requiring local environment exports or `.env` files.

## Configuration Defaults and Precedence

The configuration follows a clear precedence chain:

- **Explicit environment variables** override all other settings
- **[`reclip.sh`](https://github.com/averygan/reclip/blob/main/reclip.sh) defaults**: The script sets `PORT=8899` only if the variable is undefined (lines 50-52)
- **[`app.py`](https://github.com/averygan/reclip/blob/main/app.py) hardcoded defaults**: `PORT=8899` and `HOST="127.0.0.1"` serve as final fallbacks at lines 108-110

Note that [`reclip.sh`](https://github.com/averygan/reclip/blob/main/reclip.sh) does not provide a default `HOST` value, so you must explicitly set this variable when requiring external network access.

## Summary

- ReClip reads `PORT` and `HOST` from environment variables in [`app.py`](https://github.com/averygan/reclip/blob/main/app.py) (lines 108-110)
- Default values are `8899` for port and `127.0.0.1` for host binding
- The [`reclip.sh`](https://github.com/averygan/reclip/blob/main/reclip.sh) script sets a default `PORT` if unset, but leaves `HOST` configuration to the user
- Docker deployments can utilize `.env` files or inline `-e` flags to configure these values
- Setting `HOST=0.0.0.0` enables access from external machines

## Frequently Asked Questions

### What is the default port for ReClip?

ReClip defaults to port `8899` when the `PORT` environment variable is not set. This default appears in both [`app.py`](https://github.com/averygan/reclip/blob/main/app.py) (line 109) and [`reclip.sh`](https://github.com/averygan/reclip/blob/main/reclip.sh) (line 50), ensuring consistency across different launch methods.

### How do I make ReClip accessible from other machines on my network?

Set `HOST=0.0.0.0` before starting the application. The default `127.0.0.1` binds only to localhost, while `0.0.0.0` listens on all available network interfaces, allowing external connections.

### Can I use a .env file with ReClip?

Yes. Docker Compose automatically detects `.env` files in the project root. Define `PORT` and `HOST` values there, and the [`docker-compose.yml`](https://github.com/averygan/reclip/blob/main/docker-compose.yml) will reference them using variable substitution syntax `${PORT}`.

### Where does ReClip read the port configuration?

ReClip reads port and host configuration in [`app.py`](https://github.com/averygan/reclip/blob/main/app.py) at lines 108-110 using `os.environ.get("PORT", 8899)` and `os.environ.get("HOST", "127.0.0.1")`, which check for environment variables before falling back to hardcoded defaults.