GoogleChrome/lighthouse · warning · Error

Invalid sitemap URL protocol

Error message

Invalid sitemap URL protocol

What it means

After successfully parsing the sitemap URL, verifyDirective checks that the URL's protocol is in SITEMAP_VALID_PROTOCOLS, which contains only 'https:', 'http:', and 'ftp:'. If the sitemap URL uses any other protocol (e.g., 'file:', 'ws:', or a custom scheme), this error fires. The error is caught internally by validateRobots and surfaced as a validation error item in audit results.

Source

Thrown at core/audits/seo/robots-txt.js:84

 * @param {string} directiveValue
 * @throws will throw an exception if given directive is invalid
 */
function verifyDirective(directiveName, directiveValue) {
  if (!DIRECTIVE_SAFELIST.has(directiveName)) {
    throw new Error('Unknown directive');
  }

  if (directiveName === DIRECTIVE_SITEMAP) {
    let sitemapUrl;

    try {
      sitemapUrl = new URL(directiveValue);
    } catch (e) {
      throw new Error('Invalid sitemap URL');
    }

    if (!SITEMAP_VALID_PROTOCOLS.has(sitemapUrl.protocol)) {
      throw new Error('Invalid sitemap URL protocol');
    }
  }

  if (directiveName === DIRECTIVE_USER_AGENT && !directiveValue) {
    throw new Error('No user-agent specified');
  }

  if (directiveName === DIRECTIVE_ALLOW || directiveName === DIRECTIVE_DISALLOW) {
    if (directiveValue !== '' && directiveValue[0] !== '/' && directiveValue[0] !== '*') {
      throw new Error('Pattern should either be empty, start with "/" or "*"');
    }

    const dollarIndex = directiveValue.indexOf('$');

    if (dollarIndex !== -1 && dollarIndex !== directiveValue.length - 1) {
      throw new Error('"$" should only be used at the end of the pattern');
    }
  }

View on GitHub (pinned to 9515cd4e58)

Solutions

  1. Change the sitemap URL to use http or https: Sitemap: https://example.com/sitemap.xml
  2. If using ftp, confirm it is intentional and that the FTP server serves the sitemap correctly
  3. For local development, use a local http server and reference it by http://localhost
  4. Verify no configuration tooling is injecting non-standard protocols

Example fix

# before (robots.txt)
Sitemap: file:///var/www/sitemap.xml

# after (robots.txt)
Sitemap: https://example.com/sitemap.xml
Defensive patterns

Strategy: validation

Validate before calling

// Validate sitemap URL protocol before deployment
const VALID_PROTOCOLS = new Set(['https:', 'http:', 'ftp:']);
function validateSitemapProtocol(directiveValue) {
  const url = new URL(directiveValue);
  if (!VALID_PROTOCOLS.has(url.protocol)) {
    throw new Error(`Sitemap protocol '${url.protocol}' not allowed. Use http, https, or ftp.`);
  }
}

Prevention

When it happens

Trigger: The audited site's robots.txt contains a 'Sitemap:' directive with a valid URL that uses a protocol other than http, https, or ftp. For example: 'Sitemap: file:///path/to/sitemap.xml' or 'Sitemap: ws://example.com/sitemap'. The URL parses successfully but its .protocol property is not in the allowed set.

Common situations: Local development robots.txt using file:// protocol; incorrect protocol prefix (e.g., typo like 'htp://'); non-standard protocol used intentionally for internal tooling; configuration management tool inserting the wrong protocol scheme.

Related errors


AI-assisted analysis of GoogleChrome/lighthouse@9515cd4e58 (2026-08-13). Data as JSON: /api/errors/0d5a848d7a22f943. Report an issue: GitHub.