apify/crawlee · error · Error
Cannot combine custom proxies "options.proxyUrls" with custo
Error message
Cannot combine custom proxies "options.proxyUrls" with custom generating function "options.newUrlFunction".
What it means
ProxyConfiguration supports either a static list of proxyUrls or a dynamic newUrlFunction, but not both at once — the two custom-supply mechanisms are mutually exclusive. throwCannotCombineCustomMethods is invoked from the constructor when both options are present.
Source
Thrown at packages/core/src/proxy_configuration.ts:196
/**
* Calls the custom newUrlFunction and checks format of its return value
*/
private async callNewUrlFunction(options?: { request?: Request }) {
const proxyUrl = await this.#newUrlFunction!(options);
try {
if (proxyUrl) {
new URL(proxyUrl); // eslint-disable-line no-new
}
return proxyUrl;
} catch (err) {
throw new Error(
`The provided newUrlFunction did not return a valid URL.\nCause: ${(err as Error).message}`,
);
}
}
private throwCannotCombineCustomMethods(): never {
throw new Error(
'Cannot combine custom proxies "options.proxyUrls" with custom generating function "options.newUrlFunction".',
);
}
private throwNoOptionsProvided(): never {
throw new Error('One of "options.proxyUrls" or "options.newUrlFunction" needs to be provided.');
}
}
View on GitHub (pinned to dbe57fb09c)
Solutions
- Remove proxyUrls if dynamic generation is needed, keeping only newUrlFunction.
- Remove newUrlFunction and keep the static proxyUrls list if static behavior is intended.
- Move the static list inside newUrlFunction logic if you need a hybrid (rotate from a fixed list).
- Log/inspect the merged options object to find where the extra key comes from.
Example fix
// before
const proxy = new ProxyConfiguration({ proxyUrls: ['http://p:8000'], newUrlFunction: () => pick() });
// after
const proxy = new ProxyConfiguration({ newUrlFunction: () => pick() }); Defensive patterns
Strategy: validation
Validate before calling
if (opts.proxyUrls && opts.newUrlFunction) {
throw new Error('Provide either proxyUrls or newUrlFunction, not both');
} Try / catch
try {
proxy = new ProxyConfiguration(mergedOpts);
} catch (err) {
if ((err as Error).message.includes('Cannot combine custom proxies')) {
const { proxyUrls, ...rest } = mergedOpts;
proxy = new ProxyConfiguration(rest); // prefer newUrlFunction
} else throw err;
} Prevention
- Pick one proxy supply mechanism per configuration.
- When merging configs, delete proxyUrls if newUrlFunction is present (or vice versa).
- Keep proxy config in a single typed factory.
- Note the constructor is where the conflict is detected — validate before spreading user options.
When it happens
Trigger: Calling new ProxyConfiguration({ proxyUrls: [...], newUrlFunction: fn }) — both keys present in the options object (including via a spread config that happens to include both).
Common situations: Merging default config with user config where both define proxy strategies; refactoring from proxyUrls to newUrlFunction and leaving the old key; copy-pasting two example snippets together.
Related errors
- Invalid "proxyUrl". Unsupported protocol: ${proxyUrl}.
- The `tieredProxyUrls` option has been removed in Crawlee v4.
- The provided newUrlFunction did not return a valid URL. Caus
- One of "options.proxyUrls" or "options.newUrlFunction" needs
- PlaywrightCrawlerOptions.launchContext.proxyUrl is not allow
AI-assisted analysis of apify/crawlee@dbe57fb09c (2026-08-30).
Data as JSON: /api/errors/c598ec512af879cf.
Report an issue: GitHub.