SSH connection refused: connect
I know the SSH connection works because I can connect to it via the GitHub CLI and Visual Studio Code and the web version also works. But I just cannot connect to my Codespace from my Windows machine.
Description Steps to reproduce Impact Additional context java.lang.RuntimeException: com.intellij.ssh.SshException: Connection refused: connect at com.intellij.openapi.application.impl.LaterInvocator.invokeAndWait(LaterInvocator.java:133) at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:448) at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:468) at com.github.codespaces.jetbrains.gateway.connector.CodespacesConnectorService$prepareForJetBrainsConnection$1.run(CodespacesConnectorService.kt:256) at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:429) at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressSynchronously$9(CoreProgressManager.java:513) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$new$0(ProgressRunner.java:84) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679) at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: com.intellij.ssh.SshException: Connection refused: connect at com.intellij.ssh.impl.sshj.SshjConnectionUtilKt.setUpSessionForSshJ(SshjConnectionUtil.kt:254) at com.intellij.ssh.impl.SshConnection.doSshjSshConnection(SshConnection.kt:211) at com.intellij.ssh.impl.SshConnection.access$doSshjSshConnection(SshConnection.kt:27) at com.intellij.ssh.impl.SshConnection$createSshSessionForSshj$1.invoke(SshConnection.kt:204) at com.intellij.ssh.impl.SshConnection$createSshSessionForSshj$1.invoke(SshConnection.kt:201) at com.intellij.ssh.Ssh.wrapBlockingSshCall(ssh.kt:393) at com.intellij.ssh.Ssh.wrapBlockingSshCall$default(ssh.kt:374) at com.intellij.ssh.impl.SshConnection.createSshSessionForSshj(SshConnection.kt:201) at com.intellij.ssh.impl.SshConnection.access$createSshSessionForSshj(SshConnection.kt:27) at com.intellij.ssh.impl.SshConnection$createSession$1.invoke(SshConnection.kt:189) at com.intellij.ssh.impl.SshConnection$createSession$1.invoke(SshConnection.kt:186) at com.intellij.ssh.Ssh.wrapBlockingSshCall(ssh.kt:393) at com.intellij.ssh.Ssh.wrapBlockingSshCall$default(ssh.kt:374) at com.intellij.ssh.impl.SshConnection.createSession(SshConnection.kt:186) at com.intellij.ssh.impl.SshConnection.access$createSession(SshConnection.kt:27) at com.intellij.ssh.impl.SshConnection$openChannel$1.invoke(SshConnection.kt:91) at com.intellij.ssh.impl.SshConnection$openChannel$1.invoke(SshConnection.kt:56) at com.intellij.ssh.Ssh.wrapBlockingSshCall(ssh.kt:393) at com.intellij.ssh.Ssh.wrapBlockingSshCall$default(ssh.kt:374) at com.intellij.ssh.impl.SshConnection.openChannel(SshConnection.kt:56) at com.intellij.ssh.SshConnectionService.exec(SshConnectionService.kt:215) at com.intellij.ssh.ExecBuilder.execute(ssh.kt:220) at com.intellij.ssh.ExecBuilder.execute$default(ssh.kt:214) at com.jetbrains.gateway.ssh.deploy.impl.SshCommandExecutor$executeCommand$process$1.invoke(SshCommandExecutor.kt:66) at com.jetbrains.gateway.ssh.deploy.impl.SshCommandExecutor$executeCommand$process$1.invoke(SshCommandExecutor.kt:60) at kotlinx.coroutines.InterruptibleKt.runInterruptibleInExpectedContext(Interruptible.kt:51) at kotlinx.coroutines.InterruptibleKt.access$runInterruptibleInExpectedContext(Interruptible.kt:1) at kotlinx.coroutines.InterruptibleKt$runInterruptible$2.invokeSuspend(Interruptible.kt:43) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Caused by: java.net.ConnectException: Connection refused: connect at java.base/sun.nio.ch.Net.connect0(Native Method) at java.base/sun.nio.ch.Net.connect(Net.java:579) at java.base/sun.nio.ch.Net.connect(Net.java:568) at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) at java.base/java.net.Socket.connect(Socket.java:633) at net.schmizz.sshj.SocketClient.connect(SocketClient.java:107) at com.intellij.ssh.impl.sshj.SshjConnectionUtilKt.connectPlatform(SshjConnectionUtil.kt:863) at com.intellij.ssh.impl.sshj.SshjConnectionUtilKt.setUpSessionForSshJ$lambda$11(SshjConnectionUtil.kt:224) at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699) at java.base/java.lang.Thread.run(Thread.java:833) OS: Windows OS Version: 11.0 OS Architecture: amd64 Java Version: 17.0.6 Java Runtime Version: 17.0.6+10-b829.9 Java Vendor: JetBrains s.r.o. Available CPUs: 8 Max Memory: 536870912 Free Memory: 79501312 Total Memory: 167772160 IDE Version: 2023.1.2 IDE: JetBrains Gateway 2023.1.2 Plugin Version: 0.4.0.1231 Plugin path: C:\Users\pmend\AppData\Roaming\JetBrains\JetBrainsGateway2023.1\plugins\github-codespaces-gateway Plugin ID: com.github.codespaces.jetbrains.gateway
.devcontainer.json
------------
// For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/dotnet-postgres { "name": "C# (.NET) and PostgreSQL", "dockerComposeFile": "docker-compose.yml", "service": "app", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "features": { "ghcr.io/devcontainers/features/aws-cli:1": { "version": "latest" }, "ghcr.io/devcontainers/features/sshd:1": { "version": "latest" } }
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Configure tool-specific properties.
// "customizations": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
,"forwardPorts": [53596, 5000, 5001, 5432],
"portsAttributes": {
"5001": {
"protocol": "https"
},
"53596": {
"protocol": "https"
}
}
// Use 'postCreateCommand' to run commands after the container is created.
,"postCreateCommand": "chmod +x .devcontainer/startup.sh && ./.devcontainer/startup.sh"
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
Dockerfile
----------------
FROM mcr.microsoft.com/devcontainers/dotnet:0-6.0
RUN sudo apt-get update
&& sudo apt-get install -y nodejs npm
docker-compose.yml
-----------------
version: '3.8'
services: app: build: context: . dockerfile: Dockerfile
volumes:
- ../..:/workspaces:cached
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db
# Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
# user: root
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
db: image: postgres:14.3 restart: unless-stopped volumes: - postgres-data:/var/lib/postgresql/data environment: POSTGRES_PASSWORD: fake-password POSTGRES_USER: postgres POSTGRES_DB: postgres
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
localstack: container_name: "localstack" image: localstack/localstack ports: - "127.0.0.1:4566:4566" # LocalStack Gateway - "127.0.0.1:4510-4559:4510-4559" # external services port range environment: - DEBUG=${DEBUG-} - DOCKER_HOST=unix:///var/run/docker.sock volumes: - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack" - "/var/run/docker.sock:/var/run/docker.sock" volumes: postgres-data:
Here is some more information from the logs.
2023-05-28 22:29:26,381 [ 69955] SEVERE - #c.i.o.p.Task - JetBrains Gateway 2023.1.2 Build #GW-231.9011.34 2023-05-28 22:29:26,381 [ 69955] SEVERE - #c.i.o.p.Task - JDK: 17.0.6; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o. 2023-05-28 22:29:26,381 [ 69955] SEVERE - #c.i.o.p.Task - OS: Windows 11 2023-05-28 22:29:26,382 [ 69956] SEVERE - #c.i.o.p.Task - Plugin to blame: GitHub Codespaces version: 0.4.0.1231