{"record":{"id":"84079303b3f457e9","repo":"arduino/Arduino","slug":"unable-to-connect-to-0","errorCode":null,"errorMessage":"Unable to connect to {0}","messagePattern":"Unable to connect to (.+?)","errorType":"exception","errorClass":"RunnerException","httpStatus":null,"severity":"error","filePath":"arduino-core/src/cc/arduino/packages/uploaders/SSHUploader.java","lineNumber":148,"sourceCode":"      if (!coreMissesRemoteUploadTool && mergedSketch.exists()) {\n        sketchToCopy = mergedSketch;\n      } else {\n        sketchToCopy = new CompilerUtils().findCompiledSketch(prefs);\n      }\n      scpFiles(scp, ssh, sourcePath, sketchToCopy, warningsAccumulator);\n\n      if (coreMissesRemoteUploadTool) {\n        ssh.execSyncCommand(\"merge-sketch-with-bootloader.lua /tmp/sketch.hex\", System.out, System.err);\n      }\n\n      return runUploadTool(ssh, prefs);\n    } catch (JSchException e) {\n      String message = e.getMessage();\n      if (message.contains(\"Auth cancel\") || message.contains(\"Auth fail\") || message.contains(\"authentication fail\")) {\n        return false;\n      }\n      if (e.getMessage().contains(\"Connection refused\")) {\n        throw new RunnerException(I18n.format(tr(\"Unable to connect to {0}\"), port.getAddress()));\n      }\n      throw new RunnerException(e);\n    } catch (Exception e) {\n      throw new RunnerException(e);\n    } finally {\n      if (scp != null) {\n        scp.close();\n      }\n      if (session != null) {\n        session.disconnect();\n      }\n    }\n  }\n\n  private boolean runUploadTool(SSH ssh, PreferencesMap prefs) throws Exception {\n    ssh.execSyncCommand(\"kill-bridge\");\n\n    if (verbose) {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/cc/arduino/packages/uploaders/SSHUploader.java#L130-L166","documentation":"When the SSH session to a network board fails with a JSchException whose message contains 'Connection refused', the uploader translates it into this RunnerException naming the board address. It means nothing was listening/accepting on the board's SSH port at that address.","triggerScenarios":"uploadUsingPreferences calls ssh.connect() to the board's address and the TCP connection is refused — the board's SSH daemon is not running, the address is wrong, or the board is booting/offline.","commonSituations":"Yún boards that just rebooted (SSH takes time to start), wrong IP/port configured, board firmware where sshd is disabled, or firewall/port forwarding issues.","solutions":["Confirm the board address and that port 22 is reachable (telnet/nc check)","Wait for the board to finish booting and retry","Reset or power-cycle the board","Check the board firmware includes/starts sshd; reinstall if needed"],"exampleFix":"// before\nport = 192.168.240.99 (wrong/stale)\n// after\n// discover actual address, then:\nssh root@192.168.240.1  // verify connectivity before uploading","handlingStrategy":"retry","validationCode":"// TCP reachability pre-check before SSH upload\ntry (Socket s = new Socket()) {\n    s.connect(new InetSocketAddress(host, 22), 3000); // ok\n} catch (IOException e) {\n    throw new IllegalStateException(\"Board SSH not reachable: \" + host);\n}","typeGuard":null,"tryCatchPattern":"try {\n    uploadViaSsh(port);\n} catch (RunnerException e) {\n    if (e.getMessage().startsWith(\"Unable to connect to\")) {\n        // wait for board boot, power-cycle, then retry\n        Thread.sleep(10000);\n    }\n}","preventionTips":["Wait ~30s after board reset before uploading","Confirm board IP (ping/ARP) before upload","Ensure board firmware runs sshd on port 22"],"tags":["ssh","network","connection","upload"],"backgroundTag":"connection-refused","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}