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 ${this.DEFAULT_COLLECTOR_PORT}. What it means
CollectorApi.getCollectorPort() builds the base URL for every collector call (http://0.0.0.0:<port>). If COLLECTOR_PORT is set, it is coerced with Number() and must be an integer in 1–65535; anything else (NaN, fractional, zero, negative, >65535) triggers this warning and the default port is used instead. An unset or empty variable silently uses the default with no warning. The danger is indirect: with the wrong port, subsequent calls fail and you later see "Collector API is not online" in chats.
Source
Thrown at server/utils/collectorApi/index.js:45
extensionRequestAgent = new Agent({
headersTimeout: this.extensionRequestTimeout,
bodyTimeout: this.extensionRequestTimeout,
});
/**
* 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}
*/
static getCollectorPort() {
if (!("COLLECTOR_PORT" in process.env)) return this.DEFAULT_COLLECTOR_PORT;
const port = Number(
process.env.COLLECTOR_PORT || this.DEFAULT_COLLECTOR_PORT
);
if (Number.isInteger(port) && port > 0 && port <= 65535) return port;
console.warn(
`Invalid COLLECTOR_PORT "${process.env.COLLECTOR_PORT}". Falling back to ${this.DEFAULT_COLLECTOR_PORT}.`
);
return this.DEFAULT_COLLECTOR_PORT;
}
constructor() {
const { CommunicationKey } = require("../comKey");
this.comkey = new CommunicationKey();
this.endpoint = `http://0.0.0.0:${CollectorApi.getCollectorPort()}`;
}
log(text, ...args) {
console.log(`\x1b[36m[CollectorApi]\x1b[0m ${text}`, ...args);
}
/**
* Attach options to the request passed to the collector API
* @returns {CollectorOptions}View on GitHub (pinned to 3aec848f28)
Solutions
- Set COLLECTOR_PORT to a bare integer between 1 and 65535 that matches the collector's actual listen port (e.g. COLLECTOR_PORT=8888), with no quotes, spaces, or protocol prefix.
- Verify both sides agree: the collector's own PORT/BIND settings and the server's COLLECTOR_PORT, plus any docker port mapping host:container.
- Remove the variable entirely if you want the documented default port.
- Restart the server after fixing — the endpoint string is built once in the CollectorApi constructor.
Example fix
# before (docker-compose.yml) environment: - COLLECTOR_PORT='8888' # after environment: - COLLECTOR_PORT=8888
Defensive patterns
Strategy: validation
Validate before calling
const rawPort = process.env.COLLECTOR_PORT;
if (rawPort !== undefined && rawPort !== "" && !isValidPort(rawPort)) {
throw new Error(`COLLECTOR_PORT "${rawPort}" is invalid — use an integer between 1 and 65535.`);
} Type guard
const isValidPort = (v) => {
const n = Number(v);
return Number.isInteger(n) && n > 0 && n <= 65535;
}; Prevention
- Never quote or annotate numeric env values; a compose linter (docker compose config) will render and expose such mistakes before deploy.
- When changing the collector's listen port, update it as a single variable shared by both services rather than duplicating literals.
- Assert required env shape in a preboot check so a bad port fails loudly at startup instead of degrading into 'Collector API is not online'.
When it happens
Trigger: COLLECTOR_PORT="abc" (Number → NaN), "8888.5" (not an integer), "0", "-1", "70000"/"99999" (out of range), or values with quotes/whitespace inherited from .env, docker-compose.yml, or Kubernetes env definitions.
Common situations: Quoting numeric env values (COLLECTOR_PORT='8888') in compose files, typos like COLLECTOR_PORT=88 88, pasting a protocol or service name (http://collector, collector:8888) into a port field, or changing the collector's listen port without updating the server side. The mismatch then breaks document parsing with a misleading "not online" symptom.
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/04f00af59bd67add.
Report an issue: GitHub.