Mintplex-Labs/anything-llm · warning
Invalid COLLECTOR_PORT "${process.env.COLLECTOR_PORT}". Fall
Error message
Invalid COLLECTOR_PORT "${process.env.COLLECTOR_PORT}". Falling back to ${DEFAULT_COLLECTOR_PORT}. What it means
getCollectorPort found COLLECTOR_PORT in the environment but it did not parse to an integer in 1–65535, so the collector listens on DEFAULT_COLLECTOR_PORT instead. Common culprits: trailing whitespace/quotes, letters, floats, 0, or values above 65535.
Source
Thrown at collector/utils/http/index.js:43
new URL(baseUrl);
return true;
} catch {
return false;
}
}
/**
* Gets the collector port from the environment variables.
* If the port is not set, it will fall back to the default port.
* If the port is invalid, it will log a warning and return the default port.
* @returns {number}
*/
function getCollectorPort() {
if (!("COLLECTOR_PORT" in process.env)) return DEFAULT_COLLECTOR_PORT;
const port = Number(process.env.COLLECTOR_PORT);
if (Number.isInteger(port) && port > 0 && port <= 65535) return port;
console.warn(
`Invalid COLLECTOR_PORT "${process.env.COLLECTOR_PORT}". Falling back to ${DEFAULT_COLLECTOR_PORT}.`
);
return DEFAULT_COLLECTOR_PORT;
}
module.exports = {
reqBody,
queryParams,
validBaseUrl,
getCollectorPort,
};
View on GitHub (pinned to 3aec848f28)
Solutions
- Set COLLECTOR_PORT to a plain positive integer between 1 and 65535 (e.g. COLLECTOR_PORT=8888).
- Print the variable with delimiters to reveal hidden characters: printf '[%s]' "$COLLECTOR_PORT".
- Re-save the .env file with LF line endings and no BOM.
- Confirm the container/port mapping actually uses the default port, since your configured value is being ignored.
Example fix
# before COLLECTOR_PORT="8888 " # after COLLECTOR_PORT=8888
Defensive patterns
Strategy: validation
Validate before calling
// Fail fast at container start instead of silently using the default:
const raw = process.env.COLLECTOR_PORT;
if (raw != null) {
const port = Number(raw);
if (!Number.isInteger(port) || port < 1 || port > 65535) {
throw new Error(`COLLECTOR_PORT="${raw}" is invalid — expected integer 1-65535`);
}
} Type guard
function isValidPort(value) {
const n = Number(value);
return Number.isInteger(n) && n > 0 && n <= 65535;
} Prevention
- Lint .env files for numeric variables in CI.
- Save env files with LF endings and no BOM.
- Echo variables with delimiters during deployment debugging to spot hidden characters.
- Align container port mappings with the port the collector actually logs at startup.
When it happens
Trigger: COLLECTOR_PORT set to "0", "70000", "8888 " (trailing space), "tcp://8888", or copied with quotes from documentation; .env file edited on Windows adding a BOM or CRLF that corrupts parsing.
Common situations: Docker-compose/Dockerfile ENV values quoted oddly; Kubernetes ConfigMap values with stray characters; port-forwarding mismatches because the collector is not on the port the operator thinks.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
Related errors
- Invalid COLLECTOR_PORT "${process.env.COLLECTOR_PORT}". Fall
- No LocalAI Base Path was set.
- No LocalAi token context limit was set.
- No Groq API key was set.
- KoboldCPP must have a valid base path to use for the api.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/bf84d3d834a16180.
Report an issue: GitHub.