hashicorp/nomad · error

Trying to map ports but no network interface is available

Error message

Trying to map ports but no network interface is available

What it means

The driver only knows how to publish ports when a port source exists: driverConfig.Ports entries, a group network (Ports), or a legacy task network. If none of these are present but port_map is still set, there is no network interface/ports data to map from, so the driver fails with this message.

Source

Thrown at drivers/docker/driver.go:1452

			}
		}
	case len(task.Resources.NomadResources.Networks) > 0:
		network := task.Resources.NomadResources.Networks[0]

		for _, port := range network.ReservedPorts {
			ports.addMapped(port.Label, network.IP, port.Value, driverConfig.PortMap)
		}

		for _, port := range network.DynamicPorts {
			ports.addMapped(port.Label, network.IP, port.Value, driverConfig.PortMap)
		}

	default:
		if len(driverConfig.PortMap) > 0 {
			if task.Resources.Ports != nil {
				return c, fmt.Errorf("'port_map' cannot map group network ports, use 'ports' instead")
			}
			return c, fmt.Errorf("Trying to map ports but no network interface is available")
		}
	}
	hostConfig.PortBindings = make(networkapi.PortMap, len(ports.publishedPorts))
	for port, bindings := range ports.publishedPorts {
		parsedPort := networkapi.MustParsePort(string(port))
		convertedBindings := make([]networkapi.PortBinding, len(bindings))
		for i, binding := range bindings {
			convertedBinding := networkapi.PortBinding{
				HostPort: binding.HostPort,
			}
			if binding.HostIP != "" {
				convertedBinding.HostIP = netip.MustParseAddr(binding.HostIP)
			}
			convertedBindings[i] = convertedBinding
		}
		hostConfig.PortBindings[parsedPort] = convertedBindings
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Add a group network block with named ports and use ports = [...] instead of port_map
  2. Remove the port_map stanza if the container does not need published ports
  3. Define a static/dynamic port in the network block matching the container port

Example fix

// before
group "app" {
  task "web" {
    driver "docker" { port_map { http = 8080 } }
  }
}
// after
group "app" {
  network { port "http" {} }
  task "web" {
    driver "docker" { ports = ["http"] }
  }
}
Defensive patterns

Strategy: validation

Validate before calling

if len(cfg.PortMap) > 0 && len(group.Network.Ports) == 0 {
  return errors.New("port_map set but no group network ports declared")
}

Try / catch

err := client.StartTask(task); if err != nil && strings.Contains(err.Error(), "no network interface is available") { requireNetworkBlock(job) }

Prevention

When it happens

Trigger: StartTask -> createContainerConfig hits the default case with len(driverConfig.PortMap) > 0, task.Resources.Ports == nil, and no task.Resources.NomadResources.Networks — port_map without any network block.

Common situations: Jobs with no network stanza that still carry leftover port_map config; stripped-down job specs where the network block was removed but the docker driver config was not cleaned up.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/f1b53e250c009742. Report an issue: GitHub.