hyperledger/fabric · error

no server specified

Error message

no server specified

What it means

ConfigCmd.Execute validates the discovery CLI command's inputs before building a config query. The --server flag (address of the discovery service / peer) is nil or an empty string, so there is no endpoint to send the request to. The library fails fast rather than attempting a connection with an empty address.

Source

Thrown at discovery/cmd/config.go:48

	server  *string
	channel *string
	parser  ResponseParser
}

// SetServer sets the server of the ConfigCmd
func (pc *ConfigCmd) SetServer(server *string) {
	pc.server = server
}

// SetChannel sets the channel of the ConfigCmd
func (pc *ConfigCmd) SetChannel(channel *string) {
	pc.channel = channel
}

// Execute executes the command
func (pc *ConfigCmd) Execute(conf common.Config) error {
	if pc.server == nil || *pc.server == "" {
		return errors.New("no server specified")
	}
	if pc.channel == nil || *pc.channel == "" {
		return errors.New("no channel specified")
	}

	server := *pc.server
	channel := *pc.channel

	req := discovery.NewRequest().OfChannel(channel).AddConfigQuery()
	res, err := pc.stub.Send(server, conf, req)
	if err != nil {
		return err
	}
	return pc.parser.ParseResponse(channel, res)
}

// ConfigResponseParser parses config responses
type ConfigResponseParser struct {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Pass --server <host:port> (the discovery service address) on the command line
  2. Programmatically call the server setter (e.g. configCmd.SetServer("peer0:7051")) before Execute
  3. Verify your wrapper scripts/env include the discovery server address

Example fix

// before
configCmd := discovery.NewConfigCmd()
configCmd.SetChannel("mychannel")
// after
configCmd := discovery.NewConfigCmd()
configCmd.SetServer("peer0.example.com:7051")
configCmd.SetChannel("mychannel")
Defensive patterns

Strategy: validation

Validate before calling

if server == "" {
    return errors.New("--server is required: pass the discovery service address host:port")
}
if channel == "" {
    return errors.New("--channel is required")
}

Type guard

func configCmdReady(pc *discovery.ConfigCmd, server, channel *string) bool {
    return server != nil && *server != "" && channel != nil && *channel != ""
}

Try / catch

if err := configCmd.Execute(conf); err != nil {
    if strings.Contains(err.Error(), "no server specified") {
        return fmt.Errorf("usage: discovery config --server host:port --channel name: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Running a discovery config command without specifying the server, or calling ConfigCmd.Execute with pc.server left nil/unset.

Common situations: Omitting --server (or -S) on the discovery CLI; programmatically constructing ConfigCmd without calling SetServer; config wiring that never propagated the peer address.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/3c810ecd634a5cce. Report an issue: GitHub.