oobabooga/textgen · error · Exception
you MUST enable IPv6 or IPv4 for the API to work
Error message
you MUST enable IPv6 or IPv4 for the API to work
What it means
Raised during API server startup (modules/api/script.py:576, run_server) when the bind-address list ends up empty: IPv6 was disabled (OPENEDAI_DISABLE_IPV4 unset-false path inverted — specifically api_disable_ipv4 flag / OPENEDAI_DISABLE_IPV4 env truthy) AND IPv6 was not enabled (no --api-enable-ipv6 and OPENEDAI_ENABLE_IPV6 falsy). With no address family left, uvicorn has nothing to bind.
Source
Thrown at modules/api/script.py:576
def run_server():
# Parse configuration
port = int(os.environ.get('OPENEDAI_PORT', shared.args.api_port))
port = find_available_port(port)
ssl_certfile = os.environ.get('OPENEDAI_CERT_PATH', shared.args.ssl_certfile)
ssl_keyfile = os.environ.get('OPENEDAI_KEY_PATH', shared.args.ssl_keyfile)
# In the server configuration:
server_addrs = []
if shared.args.listen and shared.args.listen_host:
server_addrs.append(shared.args.listen_host)
else:
if os.environ.get('OPENEDAI_ENABLE_IPV6', shared.args.api_enable_ipv6):
server_addrs.append('::' if shared.args.listen else '::1')
if not os.environ.get('OPENEDAI_DISABLE_IPV4', shared.args.api_disable_ipv4):
server_addrs.append('0.0.0.0' if shared.args.listen else '127.0.0.1')
if not server_addrs:
raise Exception('you MUST enable IPv6 or IPv4 for the API to work')
# Log server information
if shared.args.public_api:
_start_cloudflared(
port,
shared.args.public_api_id,
max_attempts=3,
on_start=lambda url: logger.info(f'OpenAI/Anthropic-compatible API URL:\n\n{url}/v1\n')
)
else:
url_proto = 'https://' if (ssl_certfile and ssl_keyfile) else 'http://'
urls = [f'{url_proto}[{addr}]:{port}/v1' if ':' in addr else f'{url_proto}{addr}:{port}/v1' for addr in server_addrs]
if len(urls) > 1:
logger.info('OpenAI/Anthropic-compatible API URLs:\n\n' + '\n'.join(urls) + '\n')
else:
logger.info('OpenAI/Anthropic-compatible API URL:\n\n' + '\n'.join(urls) + '\n')
# Log API keysView on GitHub (pinned to ed888c71f2)
Solutions
- If you want IPv6-only: add --api-enable-ipv6 (or env OPENEDAI_ENABLE_IPV6=1) alongside --api-disable-ipv4.
- If you want IPv4: remove --api-disable-ipv4 / unset OPENEDAI_DISABLE_IPV4 so the default 127.0.0.1 (or 0.0.0.0 with --listen) is used.
- Prefer a single explicit --listen-host over juggling the v4/v6 toggles.
Example fix
# before (startup flags) python server.py --api --api-disable-ipv4 # -> Exception: you MUST enable IPv6 or IPv4 for the API to work # after python server.py --api --api-disable-ipv4 --api-enable-ipv6
Defensive patterns
Strategy: validation
Validate before calling
import os
def validate_api_net_args(enable_ipv6: bool, disable_ipv4: bool) -> None:
if disable_ipv4 and not enable_ipv4_fallback():
raise SystemExit(
'--api-disable-ipv4 requires --api-enable-ipv6 '
'(or OPENEDAI_ENABLE_IPV6=1), otherwise there is no address to bind')
Prevention
- Set IPv4/IPv6 flags as an explicit pair in your start script; never ship only one toggle.
- Prefer --listen-host <ip> when you need a specific address family; it bypasses the v4/v6 flag matrix entirely.
- Smoke-test API startup in CI with the exact production flags.
When it happens
Trigger: Launching with --api --api-disable-ipv4 and neither --api-enable-ipv6 nor OPENEDAI_ENABLE_IPV6 set; or setting env OPENEDAI_DISABLE_IPV4=1 while relying on default IPv4-only binding.
Common situations: Users on IPv4-restricted networks disabling IPv4 to avoid dual-stack issues but forgetting the IPv6 flag; config drift after upgrading where --api-enable-ipv6 was dropped from the start script; docker setups passing only one of the two env vars.
Related errors
- flask_cloudflared not installed. Make sure you installed the
- Could not start cloudflared.
- No model specified.
- Access to non-public address {ip} is blocked
- Could not resolve hostname: {hostname}
AI-assisted analysis of oobabooga/textgen@ed888c71f2 (2026-08-15).
Data as JSON: /api/errors/82cc77dbc732f7ec.
Report an issue: GitHub.