Kong/insomnia · error · Error

Failed to fetch

Error message

Failed to fetch "${href}": ${response.status} ${response.statusText}

What it means

Raised inside the safe HTTP resolver used when linting an OpenAPI spec: an external $ref was fetched over https but the server responded with a non-success status. The message embeds the failing URL plus HTTP status code and reason text so the offending reference can be located in the spec.

Solutions

  1. Verify the referenced URL is reachable and returns 200 (check for 404/403/auth requirements)
  2. Fix typos in the $ref URL
  3. Retry if the remote server returned a transient 5xx
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/insomnia-inso/src/commands/lint-specification.ts:56 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26). Data as JSON: /api/errors/5b82bac94e0e2ca3. Report an issue: GitHub.

Appendix: source

Thrown at packages/insomnia-inso/src/commands/lint-specification.ts:56

  const records = await dns.lookup(hostname, { all: true });
  for (const { address } of records) {
    if (isPrivateOrLoopbackHost(address)) {
      throw new Error(`Failed to resolve host. "${hostname}" resolves to a private or loopback address.`);
    }
  }
}

// Note: This is duplicated in insomnia's main/lint-process.mjs. Remember to mirror changes there as well.
const safeHttpResolver = {
  async resolve(ref: { href: () => string }): Promise<string> {
    const href = ref.href();
    if (!isSafeRefUrl(href)) {
      throw new Error(`Failed to resolve "${href}". Only https URLs to public hosts are allowed.`);
    }
    await assertResolvesToPublicHost(new URL(href).hostname.toLowerCase());
    const response = await fetch(href, { redirect: 'error', signal: AbortSignal.timeout(10_000) });
    if (!response.ok) {
      throw new Error(`Failed to fetch "${href}": ${response.status} ${response.statusText}`);
    }
    return response.text();
  },
};

export const safeRefResolver = new Resolver({
  resolvers: {
    http: safeHttpResolver,
    https: safeHttpResolver,
  },
});

export const getRuleSetFileFromFolderByFilename = async (filePath: string) => {
  try {
    const filesInSpecFolder = await fs.promises.readdir(path.dirname(filePath));
    const rulesetFileName = filesInSpecFolder.find(file => file.startsWith('.spectral'));
    if (rulesetFileName) {
      logger.trace(`Loading ruleset from \`${rulesetFileName}\``);

View on GitHub (pinned to d9bb2b0142)