{"record":{"id":"1246ab6569078d29","repo":"symfony/var-dumper","slug":"server-start-failed-on-s","errorCode":null,"errorMessage":"Server start failed on \"%s\": ","messagePattern":"Server start failed on \"(.+?)\": ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Server/DumpServer.php","lineNumber":49,"sourceCode":"     * @var resource|null\n     */\n    private $socket;\n\n    public function __construct(\n        string $host,\n        private ?LoggerInterface $logger = null,\n    ) {\n        if (!str_contains($host, '://')) {\n            $host = 'tcp://'.$host;\n        }\n\n        $this->host = $host;\n    }\n\n    public function start(): void\n    {\n        if (!$this->socket = stream_socket_server($this->host, $errno, $errstr)) {\n            throw new \\RuntimeException(\\sprintf('Server start failed on \"%s\": ', $this->host).$errstr.' '.$errno);\n        }\n    }\n\n    /**\n     * @param-immediately-invoked-callable $callback\n     */\n    public function listen(callable $callback): void\n    {\n        if (null === $this->socket) {\n            $this->start();\n        }\n\n        foreach ($this->getMessages() as $clientId => $message) {\n            $this->logger?->info('Received a payload from client {clientId}', ['clientId' => $clientId]);\n\n            $payload = @unserialize(base64_decode($message), ['allowed_classes' => [Data::class, Stub::class, ClassDumpStub::class]]);\n\n            // Impossible to decode the message, give up.","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/symfony/var-dumper/blob/e9d9cf5dcdd4b1b13b4504aaffd66ce4ddb5684e/Server/DumpServer.php#L31-L67","documentation":"DumpServer::start() opens a stream_socket_server on the configured host (e.g. tcp://127.0.0.1:9912). If the socket cannot be created — port already in use, permission denied, bad address — a RuntimeException is thrown appending the OS error string and errno.","triggerScenarios":"Another process (including a second server:dump instance) already listens on the port; port below 1024 without root; invalid host string like tcp://localhost:99999; firewall blocking bind.","commonSituations":"Leftover dump server from a previous run still holding the port in dev; Docker/WSL port conflicts; typo'd host/port in dump config or VAR_DUMPER_SERVER env vars.","solutions":["Kill the process already bound to the port (lsof -i :9912 / netstat) or stop the duplicate server:dump run","Choose a free port (e.g. --port=9913) and update your client VAR_DUMPER_SERVER accordingly","Verify the host string format is tcp://host:port with a port in 1-65535"],"exampleFix":"// before\n$server->start('tcp://127.0.0.1:9912'); // in use\n// after\n$server->start('tcp://127.0.0.1:9913');","handlingStrategy":"retry","validationCode":"$parts = parse_url($host);\nif (!$parts || !isset($parts['port']) || $parts['port'] < 1 || $parts['port'] > 65535) {\n    throw new \\InvalidArgumentException('Dump server host must be tcp://host:port with a valid port');\n}\n$conn = @fsockopen($parts['host'] ?? '127.0.0.1', $parts['port'], $errno, $errstr, 1);\nif (is_resource($conn)) {\n    fclose($conn);\n    throw new \\RuntimeException(\"Port {$parts['port']} already in use\");\n}","typeGuard":"function isBindableAddress(string $host): bool {\n    return (bool) preg_match('#^tcp:\\/\\/[\\w.\\-]+:\\d{1,5}$#', $host);\n}","tryCatchPattern":"try {\n    $server->start();\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'Server start failed')) {\n        // check port in use / pick alternate port, or surface the OS errno\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Check the port is free before starting (lsof/netstat or fsockopen probe)","Use ports above 1024 to avoid permission-denied binds","Keep host strings in tcp://host:port form and sync client VAR_DUMPER_SERVER with the chosen port","Stop stale server:dump processes from previous dev sessions"],"tags":["network","socket","server"],"backgroundTag":"address-already-in-use","analyzedSha":"e9d9cf5dcdd4b1b13b4504aaffd66ce4ddb5684e","analyzedAt":"2026-09-14T11:19:53.665Z","contentChangedAt":"2026-09-14T11:19:53.665Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}