ruvnet/RuView · error · ValueError
Redis port must be between 1 and 65535
Error message
Redis port must be between 1 and 65535
What it means
Raised by the Pydantic field_validator validate_redis_port on the Settings model in archive/v1/src/config/settings.py. Any redis_port (default 6379) outside 1..65535 makes the ValueError surface as a Pydantic ValidationError when the Settings object is built, before any Redis client is created. This mirrors the db_port check and guarantees only connectable ports are passed to get_redis_url().
Source
Thrown at archive/v1/src/config/settings.py:239
"""Validate worker count."""
if v < 1:
raise ValueError("Workers must be at least 1")
return v
@field_validator("db_port")
@classmethod
def validate_db_port(cls, v):
"""Validate database port."""
if not 1 <= v <= 65535:
raise ValueError("Database port must be between 1 and 65535")
return v
@field_validator("redis_port")
@classmethod
def validate_redis_port(cls, v):
"""Validate Redis port."""
if not 1 <= v <= 65535:
raise ValueError("Redis port must be between 1 and 65535")
return v
@field_validator("db_pool_size")
@classmethod
def validate_db_pool_size(cls, v):
"""Validate database pool size."""
if v < 1:
raise ValueError("Database pool size must be at least 1")
return v
@field_validator("monitoring_interval_seconds", "cleanup_interval_seconds", "backup_interval_seconds")
@classmethod
def validate_interval_seconds(cls, v):
"""Validate interval settings."""
if v < 0:
raise ValueError("Interval seconds must be non-negative")
return v
@propertyView on GitHub (pinned to 4685618388)
Solutions
- Set REDIS_PORT to a valid port such as 6379 (or your actual Redis port).
- If Redis is not used, disable it explicitly with REDIS_ENABLED=false rather than port 0 — note the validator still runs, so the port must be valid anyway.
- Inspect `.env`, shell environment, and compose `environment:` blocks for REDIS_PORT overrides.
- If Redis is addressed by URL, set redis_url directly and keep redis_port at its default.
Example fix
# before REDIS_PORT=0 # intent: disable Redis REDIS_ENABLED=true # after REDIS_ENABLED=false # correct way to disable REDIS_PORT=6379 # keep a valid port
Defensive patterns
Strategy: validation
Validate before calling
import os
def valid_port(name: str, default: str) -> int:
value = int(os.environ.get(name, default))
assert 1 <= value <= 65535, f'{name}={value} out of range'
return value
redis_port = valid_port('REDIS_PORT', '6379') Try / catch
from pydantic import ValidationError
try:
settings = Settings()
except ValidationError as e:
bad = [err for err in e.errors() if 'redis_port' in err['loc']]
if bad:
os.environ['REDIS_PORT'] = '6379' # corrective default
settings = Settings() Prevention
- Disable Redis with REDIS_ENABLED=false instead of port tricks.
- Keep REDIS_PORT pinned to the compose service port in one place (an .env file checked into the template).
- Document that the validator runs even when Redis is disabled.
When it happens
Trigger: Instantiating Settings with redis_port set to 0, negative, or >65535, most commonly via the REDIS_PORT environment variable. The validator runs even when redis_enabled is false, so an invalid REDIS_PORT breaks startup regardless of whether Redis is used.
Common situations: Setting REDIS_PORT=0 to turn Redis off (use REDIS_ENABLED=false instead); docker-compose files that map ports like `6379:6379` but export the container-side ephemeral value; leftover REDIS_PORT from a different service (e.g. a Node dev server port 30000+ typo); values with whitespace or quotes causing odd coercion.
Related errors
- Database port must be between 1 and 65535
- Interval seconds must be non-negative
- Threshold must be between 0.0 and 1.0
- FPS must be between 1 and 60
- Compression level must be between 1 and 9
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/9257b96b3f19eb3f.
Report an issue: GitHub.