Skip to content

Commit c9bc0c8

Browse files
committed
fix: port check ignore connection refused error
1 parent fee9d60 commit c9bc0c8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

backend/networking/ping.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ func CheckPort(host string, port string) (bool, error) {
7777
timeout := 500 * time.Millisecond
7878
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, port), timeout)
7979
if err != nil {
80-
// treat "host unreachable" and "timeout" as no error
80+
// treat "host unreachable", "connection refused" and "timeout" as no error
8181
var netErr *net.OpError
8282
if errors.As(err, &netErr) {
83-
if errors.Is(netErr.Err, syscall.EHOSTUNREACH) || netErr.Timeout() {
83+
if errors.Is(netErr.Err, syscall.EHOSTUNREACH) ||
84+
errors.Is(netErr.Err, syscall.ECONNREFUSED) ||
85+
netErr.Timeout() {
8486
return false, nil
8587
}
8688
}

0 commit comments

Comments
 (0)