{"record":{"id":"4541db1b9c419c97","repo":"linera-io/linera-protocol","slug":"a-successful-running-of-the-server","errorCode":null,"errorMessage":"a successful running of the server","messagePattern":"a successful running of the server","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"linera-storage-service/src/server.rs","lineNumber":712,"sourceCode":"            let store = database.open_shared(&[]).expect(\"Failed to open store\");\n            let store = LocalStore::RocksDb(store);\n            (store, endpoint)\n        }\n    };\n    let pending_big_puts = Arc::new(RwLock::new(BTreeMap::default()));\n    let pending_big_reads = Arc::new(RwLock::new(PendingBigReads::default()));\n    let store = StorageServer {\n        store,\n        pending_big_puts,\n        pending_big_reads,\n    };\n    let endpoint = endpoint.parse().unwrap();\n    info!(\"Starting linera_storage_service on endpoint={}\", endpoint);\n    Server::builder()\n        .add_service(StorageServiceServer::new(store))\n        .serve(endpoint)\n        .await\n        .expect(\"a successful running of the server\");\n}\n","sourceCodeStart":694,"sourceCodeEnd":714,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-storage-service/src/server.rs#L694-L714","documentation":"`Server::builder().add_service(StorageServiceServer::new(store)).serve(endpoint)` runs the tonic gRPC server on the endpoint parsed from the CLI. The future resolves with Err when the listener cannot be bound — port already in use, permission denied on a privileged port, unusable address — or when serving hits a fatal I/O error. `.expect(\"a successful running of the server\")` panics in main, so the storage service process exits.","triggerScenarios":"Starting linera-storage-service on an --endpoint whose port is already bound by another process; binding a port below 1024 without privileges; restarting immediately while the old process still holds the socket.","commonSituations":"Two instances configured with the same endpoint; a previous crashed instance's socket lingering; test harnesses racing to grab the same port; container port-mapping conflicts.","solutions":["Find and stop the holder: `ss -ltnp | grep <port>` or `lsof -i :<port>`, then restart — or pass a different --endpoint","Use an unprivileged port (>= 1024), or run with the privileges required for the chosen port","Confirm the previous instance fully exited (`ps aux | grep linera-storage-service`) before restarting"],"exampleFix":"# before\nlinera-storage-service rocksdb --endpoint 127.0.0.1:9111 ...  # port taken -> panic\n\n# after\nss -ltnp | grep 9111   # identify the holder; stop it or pick a free port\nlinera-storage-service rocksdb --endpoint 127.0.0.1:9112 ...","handlingStrategy":"validation","validationCode":"// Rust: pre-flight the port before building the server\nlet addr: std::net::SocketAddr = endpoint.parse()?;\nif let Err(e) = std::net::TcpListener::bind(addr) {\n    eprintln!(\"endpoint {addr} unavailable: {e}\");\n    std::process::exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assign each service and test a distinct endpoint from a known-free range","Add a bind pre-flight (TcpListener::bind) to startup scripts","In tests, bind port 0 and read back the OS-assigned port instead of hardcoding"],"tags":["grpc","tonic","port-in-use","server","rust"],"backgroundTag":"port-already-in-use","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}