vercel/next.js · error · Error

Failed to parse src "${src}" on `next/image`, protocol-relat

Error message

Failed to parse src "${src}" on `next/image`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)

What it means

Dev-only props validation in defaultLoader: the src starts with //, a protocol-relative URL. The image loader cannot safely guess http vs https, and such URLs break when served from file:// or non-HTTP contexts, so in development the ambiguity is rejected and an absolute scheme is demanded.

Source

Thrown at packages/next/src/shared/lib/image-loader.ts:69

    }
  }

  if (
    src.startsWith('/') &&
    src.includes('?') &&
    config.localPatterns?.length === 1 &&
    config.localPatterns[0].pathname === '**' &&
    config.localPatterns[0].search === ''
  ) {
    throw new Error(
      `Image with src "${src}" is using a query string which is not configured in images.localPatterns.` +
        `\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns`
    )
  }

  if (process.env.NODE_ENV !== 'production') {
    if (src.startsWith('//')) {
      throw new Error(
        `Failed to parse src "${src}" on \`next/image\`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)`
      )
    }

    if (src.startsWith('/') && config.localPatterns) {
      if (
        process.env.NODE_ENV !== 'test' &&
        // micromatch isn't compatible with edge runtime
        process.env.NEXT_RUNTIME !== 'edge'
      ) {
        // We use dynamic require because this should only error in development
        const { hasLocalMatch } =
          require('./match-local-pattern') as typeof import('./match-local-pattern')
        if (!hasLocalMatch(config.localPatterns, src)) {
          throw new Error(
            `Invalid src prop (${src}) on \`next/image\` does not match \`images.localPatterns\` configured in your \`next.config.js\`\n` +
              `See more info: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns`
          )

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Change the protocol-relative //src to an absolute http(s) URL.
Defensive patterns

Strategy: validation

When it happens

Trigger: next/image src is a protocol-relative URL.

Common situations: Using '//example.com/img.png' as src instead of an absolute http(s) URL.

Understand the failure class


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/467856737ef2ca64. Report an issue: GitHub.