ory/kratos · error
could not parse the endpoint URL
Error message
could not parse the endpoint URL "%s"
What it means
An endpoint string was supplied (flag or environment variable), but Go's url.Parse rejected it as malformed. The raw parse error is wrapped, so the underlying cause is a syntax problem in the URL itself, not a missing value.
Solutions
- Check the endpoint for typos: missing scheme (http:// or https://), stray whitespace, or invalid characters
- Ensure the URL has a valid host, e.g. https://kratos.example.com rather than kratos.example.com
- Quote the value in the shell to prevent glob or space issues
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cmd/cliclient/client.go:69 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ory/kratos@b86338da04 (2026-09-07).
Data as JSON: /api/errors/ea5e33d5712b4780.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/cliclient/client.go:69
return nil, errors.Errorf("ClientContextKey was expected to be *client.OryKratos but it contained an invalid type %T ", f)
}
endpoint, err := cmd.Flags().GetString(FlagEndpoint)
if err != nil {
return nil, errors.WithStack(err)
}
if endpoint == "" {
endpoint = os.Getenv(envKeyEndpoint)
}
if endpoint == "" {
return nil, errors.Errorf("you have to set the remote endpoint, try --help for details")
}
u, err := url.Parse(endpoint)
if err != nil {
return nil, errors.Wrapf(err, `could not parse the endpoint URL "%s"`, endpoint)
}
conf := kratos.NewConfiguration()
conf.HTTPClient = httpx.NewResilientClient(
httpx.ResilientClientWithConnectionTimeout(10 * time.Second),
).StandardClient()
conf.Servers = kratos.ServerConfigurations{{URL: u.String()}}
return kratos.NewAPIClient(conf), nil
}
func RegisterClientFlags(flags *pflag.FlagSet) {
flags.StringP(FlagEndpoint, FlagEndpoint[:1], "", fmt.Sprintf("The URL of Ory Kratos' Admin API. Alternatively set using the %s environmental variable.", envKeyEndpoint))
}
View on GitHub (pinned to b86338da04)