# rpc error: code = Unavailable desc = connection error: desc = "transport: authentication handshake failed: tls: first record does not look like a TLS handshake"

- **ID:** `go/grpc-permission-denied-tls`
- **Domain:** go
- **Category:** auth_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The client tried to use TLS against a plaintext gRPC server, or vice versa. Typically happens when the client uses credentials.NewTLS but the server was started without TLS credentials.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| google.golang.org/grpc 1.x | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   // server
creds, _ := credentials.NewServerTLSFromFile("server.crt", "server.key")
s := grpc.NewServer(grpc.Creds(creds))
// client
creds, _ := credentials.NewClientTLSFromFile("ca.crt", "")
conn, _ := grpc.Dial(addr, grpc.WithTransportCredentials(creds))
   ```
2. **** (85% success)
   ```
   if os.Getenv("ENV") == "local" {
    conn, _ = grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
} else {
    conn, _ = grpc.Dial(addr, grpc.WithTransportCredentials(creds))
}
   ```

## Dead Ends

- **** — The handshake fails before certificate verification; the server is not speaking TLS at all. (95% fail)
- **** — The handshake fails immediately due to protocol mismatch, not latency. (90% fail)
