appleboy / appleboy/ssh-action

Intermitttent Issue : dial tcp <ip>:22: connect: connection refused

Open
#369 1 comment 5 reactions 1 assignee Claimed by @appleboy View on GitHub
bug
Dominant language
Shell
Stars
6.2k
Forks
679
Avg merge
35m
Merged PRs (30d)
1

Description

## Describe the bug

We are intermittently encountering an issue where we are unable to connect to a VM. Before attempting to connect, we proactively check whether the machine is online. Only if it is online do we proceed with the connection using the SSH GitHub Action. Despite these precautions, the issue occurs occasionally, but it mostly resolves after a rerun.

Error we get

![Image](https://github.com/user-attachments/assets/0eb48913-0914-4232-ad82-33346a1eb5ac)

## Yaml Config

Please post your Yaml configuration file along with the output results.

```yaml
- name: Wait for machine to be online
run: |
while ! nc -w10 -z -v $vmIpAddress 22;do echo "Waiting for machine to be online..."; done
id: vm_ip_address

- name: Exporting variables to bash profile
uses: appleboy/ssh-action@master
with:
command_timeout: 60m
host: ${{ steps.vm_ip_address.outputs.IP_ADDRESS }}
username: azureuser
key: ${{ secrets.PRIVATE_KEY }}
port: 22
script: |
HOME_DIR="/home/azureuser"
```

![Image](https://github.com/user-attachments/assets/4e103c8b-de7e-42ea-a2dd-b612b05cd317)

## Related environment

Please provide the following information:

1. Your hosting provider information, such as DigitalOcean, Linode, AWS, or GCP.
- Azure
2. The version information of your host's SSH service.
- latest ('@master')
3. The information from your host's SSH configuration file.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.