{"record":{"id":"536147e9a862fe58","repo":"navidrome/navidrome","slug":"running-server-w","errorCode":null,"errorMessage":"running server: %w","messagePattern":"running server: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/server.go","lineNumber":129,"sourceCode":"\t\t}\n\t}()\n\n\t// Measure server startup time\n\tstartupTime := time.Since(consts.ServerStart)\n\n\t// Wait a short time to make sure the server has started successfully\n\tselect {\n\tcase err := <-errC:\n\t\tlog.Error(ctx, \"Could not start server. Aborting\", err)\n\t\treturn fmt.Errorf(\"starting server: %w\", err)\n\tcase <-time.After(50 * time.Millisecond):\n\t\tlog.Info(ctx, \"----> Navidrome server is ready!\", \"address\", addr, \"startupTime\", startupTime, \"tlsEnabled\", tlsEnabled)\n\t}\n\n\t// Wait for a signal to terminate\n\tselect {\n\tcase err := <-errC:\n\t\treturn fmt.Errorf(\"running server: %w\", err)\n\tcase <-ctx.Done():\n\t\t// If the context is done (i.e. the server should stop), proceed to shutting down the server\n\t}\n\n\t// Try to stop the HTTP server gracefully\n\tlog.Info(ctx, \"Stopping HTTP server\")\n\tctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)\n\tdefer cancel()\n\tserver.SetKeepAlivesEnabled(false)\n\tif err := server.Shutdown(ctx); err != nil && !errors.Is(err, context.DeadlineExceeded) {\n\t\tlog.Error(ctx, \"Unexpected error in http.Shutdown()\", err)\n\t}\n\treturn nil\n}\n\nfunc createUnixSocketFile(socketPath string, socketPerm string) (net.Listener, error) {\n\t// Remove the socket file if it already exists\n\tif err := os.Remove(socketPath); err != nil && !os.IsNotExist(err) {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/navidrome/navidrome/blob/4ed7494a3293a9e9e647897ebfb9be327efd981b/server/server.go#L111-L147","documentation":"After successful startup, Run() blocks on errC; if the background goroutine sends an error while the server is running (Serve() returned unexpectedly), it is wrapped with 'running server'. This means the HTTP server crashed mid-operation rather than at boot.","triggerScenarios":"http.Server.Serve() returns a non-ErrServerClosed error while running — e.g. listener I/O failure, accept errors beyond limits, abrupt network device removal.","commonSituations":"Network interface going down on a NAS; firewall/conntrack issues killing the listening socket; container runtime networking failures; resource exhaustion causing accept errors.","solutions":["Inspect the wrapped cause in logs and fix the underlying listener/network condition","Restart the service (systemd restart navidrome) or run it under a supervisor with automatic restart","Check dmesg/system logs for network device or resource (fd/memory) errors","Verify stable networking in containerized deployments (host vs bridge networking)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := srv.Run(ctx)\nif err != nil && strings.HasPrefix(err.Error(), \"running server\") {\n    log.Errorf(\"server stopped unexpectedly: %v — restarting under supervisor\", err)\n    // systemd Restart=on-failure handles this automatically\n}","preventionTips":["Configure systemd Restart=on-failure or a container restart policy","Monitor network interface health on long-running NAS devices","Watch file-descriptor and memory limits to avoid accept failures","Alert on process exit so the crash is noticed"],"tags":["network","http-server","runtime","crash"],"backgroundTag":"server-runtime-crash","analyzedSha":"4ed7494a3293a9e9e647897ebfb9be327efd981b","analyzedAt":"2026-09-01T05:03:05.018Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}