hashicorp/nomad · error
Connect configuration empty for service %s
Error message
Connect configuration empty for service %s
What it means
newConnect builds a Consul AgentServiceConnect from a task's service definition. The 'default' branch of the switch is reached when the service has a non-nil but completely empty (zero-valued) connect block — no sidecar, no gateway, no native config — which is semantically meaningless, so Nomad rejects it.
Source
Thrown at command/agent/consul/connect.go:49
case nc.IsNative():
// the service is connect native
return &api.AgentServiceConnect{Native: true}, nil
case nc.HasSidecar():
// must register the sidecar for this service
if nc.SidecarService.Port == "" {
nc.SidecarService.Port = fmt.Sprintf("%s-%s", structs.ConnectProxyPrefix, serviceName)
}
sidecarReg, err := connectSidecarRegistration(serviceID, info, nc.SidecarService, networks, ports)
if err != nil {
return nil, err
}
return &api.AgentServiceConnect{SidecarService: sidecarReg}, nil
default:
// a non-nil but empty connect block makes no sense
return nil, fmt.Errorf("Connect configuration empty for service %s", serviceName)
}
}
// newConnectGateway creates a new Consul AgentServiceConnectProxyConfig struct based on
// a Nomad Connect struct. If the Nomad Connect struct does not contain a gateway, nil
// will be returned as this service is not a gateway.
func newConnectGateway(connect *structs.ConsulConnect) *api.AgentServiceConnectProxyConfig {
if !connect.IsGateway() {
return nil
}
var envoyConfig map[string]any
// Populate the envoy configuration from the gateway.proxy block, if
// such configuration is provided.
if proxy := connect.Gateway.Proxy; proxy != nil {
envoyConfig = make(map[string]any)
View on GitHub (pinned to 482b49bf1a)
Solutions
- Populate the connect block: add a sidecar_service block, a gateway (ingress/terminating/mesh), or set native = true.
- Remove the connect block entirely if Connect is not intended for this service.
- Validate the job with nomad job validate before submission to catch the empty block.
Example fix
// before
service {
name = "web"
connect {}
}
// after
service {
name = "web"
connect {
sidecar_service {}
}
} Defensive patterns
Strategy: validation
Validate before calling
func connectBlockEmpty(c *structs.ConsulConnect) bool {
return c != nil && c.SidecarService == nil && c.Gateway == nil && !c.Native
}
if connectBlockEmpty(svc.Connect) {
return fmt.Errorf("service %s: connect block is empty", svc.Name)
} Prevention
- Never emit an empty connect stanza in HCL/JSON jobs.
- Always pair connect with sidecar_service, gateway, or native = true.
- Run nomad job validate before submitting jobs.
When it happens
Trigger: Declaring a connect stanza in a Nomad service that sets nothing (e.g. connect {} with no sidecar_service, gateway, or native), causing newConnect to fall through to the default case.
Common situations: Job authors write an empty connect block intending to enable sidecars but forget to configure the sidecar_service or gateway; jobs copied from examples where the meaningful fields were stripped.
Related errors
- consul address must be set on nomad client
- error creating bootstrap configuration for Connect proxy sid
- Service with provider nomad cannot include Connect blocks
- missing %q
- Connect only supported with exactly 1 network (found %d)
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/06b1a90857c7752a.
Report an issue: GitHub.