shadcn-ui/ui · error
Failed to fetch registries.
Error message
Failed to fetch registries.
What it means
When at least one registry arg lacks an explicit URL, the CLI calls getRegistries() to look up the official index. If that returns null — network error, non-200, or unparseable response — the spinner fails and this throws.
Source
Thrown at packages/shadcn/src/commands/registry/add.ts:97
if (!fs.existsSync(configPath)) {
throw new Error(
`No ${highlighter.info("components.json")} found. Run ${highlighter.info(
"shadcn init"
)} first.`
)
}
const parsed = registryArgs.map(parseRegistryArg)
const needsLookup = parsed.filter((p) => !p.url)
let registriesIndex: { name: string; url: string }[] = []
if (needsLookup.length > 0) {
const fetchSpinner = spinner("Fetching registries.", {
silent: options.silent,
}).start()
const registries = await getRegistries()
if (!registries) {
fetchSpinner.fail()
throw new Error("Failed to fetch registries.")
}
fetchSpinner.succeed()
registriesIndex = registries
}
const registriesToAdd: Record<string, string> = {}
for (const { namespace, url } of parsed) {
if (namespace in BUILTIN_REGISTRIES) {
logger.warn(
`${highlighter.info(
namespace
)} is a built-in registry and cannot be added.`
)
continue
}
if (url) {
if (!url.includes("{name}")) {View on GitHub (pinned to efac598707)
Solutions
- Provide the URL explicitly to skip the lookup: `shadcn registry add @acme=https://example.com/r/{name}.json`.
- Check connectivity to the shadcn registry host.
- Retry; the endpoint may be transiently unavailable.
- Configure HTTP_PROXY / HTTPS_PROXY if behind a corporate network.
Example fix
// before
shadcn registry add @acme
// after (offline-safe)
shadcn registry add @acme=https://my-cdn.example.com/r/{name}.json Defensive patterns
Strategy: fallback
Validate before calling
// Skip the network lookup by always supplying an explicit URL template.
const arg = `@acme=https://my-cdn.example.com/r/{name}.json` Try / catch
try {
await addRegistriesToConfig(["@acme"], cwd, {})
} catch (e) {
if (e instanceof Error && /Failed to fetch registries/.test(e.message)) {
// Fallback: supply the URL inline to avoid the index lookup.
return addRegistriesToConfig(["@acme=https://my-cdn.example.com/r/{name}.json"], cwd, {})
}
throw e
} Prevention
- Pin registry URLs in components.json so future adds skip the network lookup.
- Add retry/backoff around registry fetches when running in CI.
When it happens
Trigger: Running `shadcn registry add @somename` (no inline URL) while offline, behind a blocking proxy, or when the shadcn registries endpoint is unreachable or returns invalid JSON.
Common situations: No internet, corporate proxy/firewall blocking ui.shadcn.com, DNS failure, endpoint temporarily down, response schema change between versions.
Related errors
- Failed to fetch registry item: ${response.statusText}
- Something went wrong fetching the registry icons.
- Failed to fetch components from registry.
- Failed to fetch components from registry.
- Failed to fetch components from registry.
AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12).
Data as JSON: /api/errors/fed7b96f7b9bd4f9.
Report an issue: GitHub.