xxxxxxxxxx
//sometimes this error caused by an active VPN extension.
//Disable any such extension and try again. it will work
xxxxxxxxxx
package main
import (
"fmt"
"net"
)
func main() {
address := "127.0.0.1:8080"
conn, err := net.Dial("tcp", address)
if err != nil {
fmt.Printf("Dial error: %v\n", err)
return
}
defer conn.Close()
// Handle successful connection here
fmt.Println("Connected successfully.")
}