# Startup Configuration

Startup configuration defines the process-level settings AISIX needs before it can serve traffic. It controls how the gateway receives dynamic resources, which listeners it binds, which shared backends it uses, and how it connects to an AISIX Enterprise or AISIX Cloud control plane.

Dynamic resources are configured separately. Models, provider keys, caller API keys, guardrails, cache policies, rate-limit policies, and observability exporters come from a resources file, a configuration store, or an AISIX Enterprise or AISIX Cloud control plane.

## Understand the Configuration Sources[​](#understand-the-configuration-sources "Direct link to Understand the Configuration Sources")

AISIX uses different configuration sources for different responsibilities:

| Configuration             | Applies To                                           | Source                                                                  |
| ------------------------- | ---------------------------------------------------- | ----------------------------------------------------------------------- |
| Process settings          | Every gateway                                        | Startup configuration file with optional environment-variable overrides |
| Dynamic gateway resources | AISIX OSS                                            | Declarative `resources.yaml` file or etcd                               |
| Dynamic gateway resources | Gateway connected to AISIX Enterprise or AISIX Cloud | The corresponding product's control plane                               |
| Control-plane settings    | AISIX Enterprise                                     | Docker Compose environment variables or Helm values                     |

This page covers gateway startup configuration. For AISIX Enterprise control-plane settings, see the [AISIX Enterprise Configuration Reference](https://docs.api7.ai/ai-gateway/reference/on-premises-configuration.md).

## Choose the Dynamic-Resource Source[​](#choose-the-dynamic-resource-source "Direct link to Choose the Dynamic-Resource Source")

A gateway reads dynamic resources from one source. Choose that source in startup configuration before configuring listeners and runtime dependencies.

### Resources File[​](#resources-file "Direct link to Resources File")

Use a declarative resources file for the normal open-source AISIX gateway workflow:

config.yaml

```
resources_file: /etc/aisix/resources.yaml



proxy:

  addr: "0.0.0.0:3000"



admin:

  enabled: false



observability:

  metrics:

    prometheus:

      enabled: true

      path: "/metrics"

      addr: "0.0.0.0:9090"
```

The gateway loads the file at startup and reloads it on `SIGHUP`. Validate resource changes before applying them:

```
aisix validate --resources /etc/aisix/resources.yaml
```

See the [AISIX OSS getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart.md) for the complete workflow and the [Resources File Reference](https://docs.api7.ai/ai-gateway/reference/resources-file.md) for supported resource kinds.

### Configuration Store[​](#configuration-store "Direct link to Configuration Store")

Use etcd when an existing automation system manages open-source AISIX gateway resources through a shared store:

config.yaml

```
etcd:

  endpoints:

    - "http://127.0.0.1:2379"

  prefix: "/aisix"
```

Keep the prefix stable across gateway instances that should receive the same resources. Use `env_id` only when the configuration system writes environment-scoped keys. Configure `etcd.tls` when the store requires mTLS.

`etcd.dial_timeout_ms` defaults to 5000 milliseconds and `etcd.request_timeout_ms` is unset by default, which leaves the configuration read unbounded. Before setting either, review their exact scope and failure behavior in [etcd Configuration Store](https://docs.api7.ai/ai-gateway/reference/configuration-files.md#etcd-configuration-store). A `request_timeout_ms` that is too short for the configuration read can prevent the proxy listener from binding or leave a running gateway behind the store.

When etcd cannot provide the first configuration, the gateway normally keeps the proxy listener closed and retries. See [The Gateway Runs but the Proxy Port Refuses Connections](https://docs.api7.ai/ai-gateway/deployment/troubleshooting.md#the-gateway-runs-but-the-proxy-port-refuses-connections) to distinguish reachability, timeout, and credential failures.

The configuration source is the only startup dependency that can hold the proxy listener closed indefinitely. An unreachable `ratelimit.redis` or `cache.redis` can delay all listeners while AISIX makes bounded startup connection attempts. After those attempts finish, Redis no longer blocks listener startup and the affected subsystem enters a degraded mode. Each listener must still meet its own enablement and configuration conditions.

Do not configure both `resources_file` and `etcd`; AISIX rejects that combination at startup.

### AISIX Enterprise or AISIX Cloud[​](#aisix-enterprise-or-aisix-cloud "Direct link to AISIX Enterprise or AISIX Cloud")

The generated gateway installation snippet sets `managed.enabled` to `true` and supplies the control-plane endpoint, certificate bundle, runtime state directory, and gateway identity path. The gateway then receives environment resources from the control plane.

Do not combine `managed.enabled: true` with `resources_file`. Follow [Connect a Gateway](https://docs.api7.ai/ai-gateway/cloud/connect-a-gateway.md) for certificate issuance and the complete connection workflow.

## Configure Shared Runtime State[​](#configure-shared-runtime-state "Direct link to Configure Shared Runtime State")

AISIX always has an in-process response cache. Configure Redis when cache policies should share entries across gateway instances:

config.yaml

```
cache:

  redis:

    mode: single

    url: "redis://127.0.0.1:6379"
```

Configuring `cache.redis` makes Redis available to cache policies. Each cache policy selects memory or Redis.

Rate-limit counters use process memory by default. Configure a shared Redis backend when request, token, or concurrency limits must apply across multiple instances:

config.yaml

```
ratelimit:

  backend: redis

  redis:

    mode: single

    url: "redis://127.0.0.1:6379"
```

Cache and rate-limit Redis connections support single-node, cluster, and Sentinel deployments. Use an available Redis topology when either feature is part of the production traffic path.

## Configure Runtime Listeners[​](#configure-runtime-listeners "Direct link to Configure Runtime Listeners")

AISIX separates caller traffic from operational status:

| Listener       | Purpose                                                                                                                             | Exposure                         |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
| Proxy          | Caller-facing AI APIs and `/livez` and `/readyz`                                                                                    | Intended callers or ingress tier |
| Metrics/status | Prometheus metrics and `/status/*` routes                                                                                           | Trusted monitoring network       |
| Diagnostics    | Heap profiles at `/debug/pprof/heap`; see [Memory Diagnostics](https://docs.api7.ai/ai-gateway/observability/memory-diagnostics.md) | Loopback only, the default       |

Set an explicit proxy address. The metrics/status routes do not require application authentication, so never expose that listener publicly.

The metrics/status listener normally binds when the process starts. With etcd or an AISIX Enterprise or AISIX Cloud control plane as the resource source, the proxy listener binds only after the gateway has applied its first configuration. A resources-file gateway binds after loading the file. See [Startup and the First Configuration](https://docs.api7.ai/ai-gateway/deployment/health-checks.md#startup-and-the-first-configuration).

Use listener TLS only when AISIX should terminate HTTPS directly. Resolve forwarded client addresses only when the gateway runs behind a trusted load balancer or ingress. See [Network and Security](https://docs.api7.ai/ai-gateway/deployment/network-and-security.md) for the exposure model and [TLS and mTLS](https://docs.api7.ai/ai-gateway/deployment/tls-and-mtls.md) for the independent TLS contexts.

## Configure Process Observability[​](#configure-process-observability "Direct link to Configure Process Observability")

Startup observability settings control process logging and the metrics/status listener:

config.yaml

```
observability:

  service_name: "aisix"

  log_level: "warn"

  metrics:

    prometheus:

      enabled: true

      path: "/metrics"

      addr: "0.0.0.0:9090"
```

`log_level` defaults to `warn`. Raise it to `info` while diagnosing; startup lines such as `aisix listening` are written only at `info`, so confirm startup through [`/readyz`](https://docs.api7.ai/ai-gateway/deployment/health-checks.md#traffic-readiness). The access log is written at every level until you set `access_log: false`. See [Collect Access Logs](https://docs.api7.ai/ai-gateway/observability/access-logs-and-request-correlation.md#collect-access-logs).

These settings are different from dynamic observability exporters. Startup settings control the process and local Prometheus listener. Configure runtime telemetry delivery through [Observability Exporters](https://docs.api7.ai/ai-gateway/observability/exporters.md).

## Configure Shutdown Behavior[​](#configure-shutdown-behavior "Direct link to Configure Shutdown Behavior")

On `SIGTERM` the gateway reports itself unready straight away. It keeps accepting new connections for a further window, so the load balancer in front has time to withdraw it before the listener closes:

config.yaml

```
shutdown:

  min_drain_secs: 30
```

Set the window above the detection latency of whatever load-balances the instance, and give the platform enough termination time for the in-flight drain that follows. See [Graceful Shutdown and Draining](https://docs.api7.ai/ai-gateway/deployment/graceful-shutdown.md).

## Load and Verify the Configuration[​](#load-and-verify-the-configuration "Direct link to Load and Verify the Configuration")

AISIX applies built-in defaults, then the startup configuration file, then `AISIX_` environment-variable overrides. Use `__` between nested field names:

```
export AISIX_PROXY__ADDR="0.0.0.0:3000"
```

See the [Startup Configuration Reference](https://docs.api7.ai/ai-gateway/reference/configuration-files.md) for file formats, field behavior, file selection, and loading precedence. See [Environment Variables](https://docs.api7.ai/ai-gateway/reference/environment-variables.md) for override syntax.

After starting the gateway, check whether AISIX has applied a valid configuration on the metrics/status listener:

```
curl -sSi "http://127.0.0.1:9090/status/ready"

curl -sS "http://127.0.0.1:9090/status/config"
```

Once `/status/ready` returns `200`, check the proxy listener:

```
curl -i "http://127.0.0.1:3000/livez"

curl -i "http://127.0.0.1:3000/readyz"
```

If these commands are refused, use the metrics/status results and [Troubleshooting](https://docs.api7.ai/ai-gateway/deployment/troubleshooting.md#the-gateway-runs-but-the-proxy-port-refuses-connections) to diagnose why the first configuration has not been applied. If they answer but a resource change is missing, use [Configuration Propagation](https://docs.api7.ai/ai-gateway/deployment/configuration-propagation.md) to trace the change from its source to the caller-facing path.

## Next Steps[​](#next-steps "Direct link to Next Steps")

Continue with [Thread-per-Core Workers](https://docs.api7.ai/ai-gateway/deployment/thread-per-core-workers.md) to size the worker pool behind the proxy listener, then [Network and Security](https://docs.api7.ai/ai-gateway/deployment/network-and-security.md) to protect the listeners, stores, and credentials configured here.
