{"record":{"id":"3ef29895c7a68412","repo":"kataras/iris","slug":"build-inject-live-reload-failed-v","errorCode":null,"errorMessage":"build: inject live reload: failed: %v","messagePattern":"build: inject live reload: failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"iris.go","lineNumber":750,"sourceCode":"\t}\n\n\tif app.view.Registered() {\n\t\tapp.logger.Debugf(\"Application: view engine %q is registered\", app.view.Name())\n\t\t// view engine\n\t\t// here is where we declare the closed-relative framework functions.\n\t\t// Each engine has their defaults, i.e yield,render,render_r,partial, params...\n\t\trv := router.NewRoutePathReverser(app.APIBuilder)\n\t\tapp.view.AddFunc(\"urlpath\", rv.Path)\n\t\t// app.view.AddFunc(\"url\", rv.URL)\n\t\tif err := app.view.Load(); err != nil {\n\t\t\treturn fmt.Errorf(\"build: view engine: %v\", err)\n\t\t}\n\t}\n\n\tif !app.Router.Downgraded() {\n\t\t// router\n\t\tif _, err := injectLiveReload(app); err != nil {\n\t\t\treturn fmt.Errorf(\"build: inject live reload: failed: %v\", err)\n\t\t}\n\n\t\tif app.config.ForceLowercaseRouting {\n\t\t\t// This should always be executed first.\n\t\t\tapp.Router.PrependRouterWrapper(func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\n\t\t\t\tr.Host = strings.ToLower(r.Host)\n\t\t\t\tr.URL.Host = strings.ToLower(r.URL.Host)\n\t\t\t\tr.URL.Path = strings.ToLower(r.URL.Path)\n\t\t\t\tnext(w, r)\n\t\t\t})\n\t\t}\n\n\t\t// create the request handler, the default routing handler\n\t\trouterHandler := router.NewDefaultHandler(app.config, app.logger)\n\t\terr := app.Router.BuildRouter(app.ContextPool, routerHandler, app.APIBuilder, false)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"build: router: %w\", err)\n\t\t}","sourceCodeStart":732,"sourceCodeEnd":768,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/iris.go#L732-L768","documentation":"During Application.Build(), Iris injects the live-reload middleware (used when Configurator enables it, e.g. injected via injectLiveReload) and wraps any failure as 'build: inject live reload: failed: %v'. The live reload component watches/patches assets and needs an available reload address; if it cannot be initialized the build aborts.","triggerScenarios":"Enabling live reload features (e.g. via app configuration used by the iris-cli/dev flow) when the reload websocket/proxy cannot be set up — e.g. port conflict, invalid tunneling/reload config, or an error returned by injectLiveReload(app).","commonSituations":"Running behind a reverse proxy that blocks the reload route/port; another dev server already bound to the live-reload port; misconfigured Reload address in dev tooling; running in environments where the watcher cannot spawn.","solutions":["Read the wrapped inner error after 'failed:' to identify the underlying cause (usually bind/port or config).","Disable live reload for this environment (do not enable the reload configurator in production/CI).","Free the port used by live reload or change its configured address.","If behind a proxy, forward or exclude the live-reload endpoint.","Upgrade Iris if the inner error points to an injectLiveReload bug."],"exampleFix":"// before (dev-only option enabled everywhere)\napp.Configure(iris.WithLiveReload)\n// after\nif isDev {\n    app.Configure(iris.WithLiveReload)\n}","handlingStrategy":"fallback","validationCode":"if liveReloadEnabled && isProd() {\n    log.Fatal(\"live reload must be disabled in production\")\n}\nif ln, err := net.Listen(\"tcp\", reloadAddr); err != nil {\n    log.Fatalf(\"live reload port %s unavailable: %v\", reloadAddr, err)\n} else { ln.Close() }","typeGuard":null,"tryCatchPattern":"if err := app.Build(); err != nil && strings.Contains(err.Error(), \"inject live reload\") {\n    log.Printf(\"live reload unavailable (%v); continuing without it\", err)\n} else if err != nil {\n    log.Fatal(err)\n}","preventionTips":["Enable live reload only in dev builds (build tags or env checks).","Check port availability before enabling.","Exclude live-reload endpoints in proxy configs."],"tags":["go","iris","live-reload","startup","devtools"],"backgroundTag":"middleware-injection-failed","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}