{"record":{"id":"bd3e6b9a7e7a81f7","repo":"glanceapp/glance","slug":"starting-server-w","errorCode":null,"errorMessage":"starting server: %w","messagePattern":"starting server: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/glance/main.go","lineNumber":175,"sourceCode":"\tstopWatching, err := configFilesWatcher(configPath, configContents, configIncludes, onChange, onErr)\n\tif err == nil {\n\t\tdefer stopWatching()\n\t} else {\n\t\tlog.Printf(\"Error starting file watcher, config file changes will require a manual restart. (%v)\", err)\n\n\t\tconfig, err := newConfigFromYAML(configContents)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"validating config file: %w\", err)\n\t\t}\n\n\t\tapp, err := newApplication(config)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"creating application: %w\", err)\n\t\t}\n\n\t\tstartServer, _ := app.server()\n\t\tif err := startServer(); err != nil {\n\t\t\treturn fmt.Errorf(\"starting server: %w\", err)\n\t\t}\n\t}\n\n\t<-exitChannel\n\treturn nil\n}\n\nfunc serveUpdateNoticeIfConfigLocationNotMigrated(configPath string) bool {\n\tif !isRunningInsideDockerContainer() {\n\t\treturn false\n\t}\n\n\tif _, err := os.Stat(configPath); err == nil {\n\t\treturn false\n\t}\n\n\t// glance.yml wasn't mounted to begin with or was incorrectly mounted as a directory\n\tif stat, err := os.Stat(\"glance.yml\"); err != nil || stat.IsDir() {","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/main.go#L157-L193","documentation":"Startup error returned when app.server()'s startServer() fails in the watcher-less fallback path. Server startup binds the configured host:port and starts TLS/HTTP serving; failure is dominated by 'address already in use' and permission errors on privileged/unsupported bind addresses.","triggerScenarios":"Another process already listening on server.port; binding to a port <1024 without CAP_NET_BIND_SERVICE; binding to an IP not present on the host; TLS cert/key files unreadable when TLS is configured.","commonSituations":"Double-starting glance (old container still running); port collision with another service after a config change; Docker port mapping mismatch; systemd unit and manual run racing each other.","solutions":["Free the port: stop the old instance (`docker stop`, `kill`) or change server.port","If binding <1024, use setcap/PORT env or pick a high port","Confirm the bind host exists on the machine (0.0.0.0 vs a specific IP)","Check TLS file paths/permissions if TLS is enabled"],"exampleFix":"# before\nserver:\n  port: 8080   # already in use\n# after\nserver:\n  port: 8090\n","handlingStrategy":"retry","validationCode":"// Check port availability before starting\nln, err := net.Listen(\"tcp\", fmt.Sprintf(\"%s:%d\", host, port))\nif err != nil { return fmt.Errorf(\"port not available: %w\", err) }\nln.Close()\n","typeGuard":null,"tryCatchPattern":"Catch 'starting server'; if the wrapped error is EADDRINUSE, wait briefly and retry once after confirming the old process exited; otherwise fail with the bind error.","preventionTips":["Reserve a dedicated port per glance instance","Use systemd/docker restart policies with stop-timeout so old listeners release first","Avoid privileged ports unless the runtime has CAP_NET_BIND_SERVICE"],"tags":["server","network","port-binding","startup"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}