diff --git a/command/agent/command.go b/command/agent/command.go index 400b27153a..8f9a8712f6 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -1082,7 +1082,13 @@ func (c *Command) Run(args []string) int { } // Get the new client http listener addr - httpAddr, err := config.ClientListener(config.Addresses.HTTP, config.Ports.HTTP) + var httpAddr net.Addr + var err error + if config.Ports.HTTP != -1 { + httpAddr, err = config.ClientListener(config.Addresses.HTTP, config.Ports.HTTP) + } else { + httpAddr, err = config.ClientListener(config.Addresses.HTTPS, config.Ports.HTTPS) + } if err != nil { c.Ui.Error(fmt.Sprintf("Failed to determine HTTP address: %v", err)) } @@ -1092,7 +1098,12 @@ func (c *Command) Run(args []string) int { go func(wp *watch.WatchPlan) { wp.Handler = makeWatchHandler(logOutput, wp.Exempt["handler"]) wp.LogOutput = c.logOutput - if err := wp.Run(httpAddr.String()); err != nil { + addr := httpAddr.String() + // If it's a unix socket, prefix with unix:// so the client initializes correctly + if httpAddr.Network() == "unix" { + addr = "unix://" + addr + } + if err := wp.Run(addr); err != nil { c.Ui.Error(fmt.Sprintf("Error running watch: %v", err)) } }(wp)