Unavailable dotnet network_error ai_generated true

Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="failed to connect to all addresses; last error: UNKNOWN: ipv4:192.168.1.1:443: No connection could be made because the target machine actively refused it.")

ID: dotnet/grpc-unavailable-connectivity

Also available as: JSON · Markdown · 中文
85%Fix Rate
85%Confidence
1Evidence
2023-04-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
net6.0 active
net7.0 active
net8.0 active
net9.0 active

Root Cause

The gRPC client cannot reach the server because the server is not running, the port is blocked by a firewall, or the endpoint address is incorrect.

generic

中文

gRPC 客户端无法到达服务器,因为服务器未运行、端口被防火墙阻止或端点地址不正确。

Official Documentation

https://learn.microsoft.com/en-us/aspnet/core/grpc/troubleshoot?view=aspnetcore-8.0

Workarounds

  1. 90% success Verify the server is running and listening on the expected port. Use 'netstat -an | findstr :443' (Windows) or 'ss -tuln | grep 443' (Linux) to check. Restart the gRPC server service if needed.
    Verify the server is running and listening on the expected port. Use 'netstat -an | findstr :443' (Windows) or 'ss -tuln | grep 443' (Linux) to check. Restart the gRPC server service if needed.
  2. 85% success Check firewall rules. For Windows, run 'netsh advfirewall firewall add rule name="gRPC" dir=in action=allow protocol=TCP localport=443'. For Linux, use 'ufw allow 443/tcp' or adjust iptables.
    Check firewall rules. For Windows, run 'netsh advfirewall firewall add rule name="gRPC" dir=in action=allow protocol=TCP localport=443'. For Linux, use 'ufw allow 443/tcp' or adjust iptables.
  3. 80% success Ensure the client endpoint URL matches the server's listening address. For example, if the server uses 'https://localhost:5001', the client should set 'new GrpcChannel.ForAddress("https://localhost:5001")'. Use DNS resolution with 'nslookup server.example.com' to verify IP.
    Ensure the client endpoint URL matches the server's listening address. For example, if the server uses 'https://localhost:5001', the client should set 'new GrpcChannel.ForAddress("https://localhost:5001")'. Use DNS resolution with 'nslookup server.example.com' to verify IP.

中文步骤

  1. Verify the server is running and listening on the expected port. Use 'netstat -an | findstr :443' (Windows) or 'ss -tuln | grep 443' (Linux) to check. Restart the gRPC server service if needed.
  2. Check firewall rules. For Windows, run 'netsh advfirewall firewall add rule name="gRPC" dir=in action=allow protocol=TCP localport=443'. For Linux, use 'ufw allow 443/tcp' or adjust iptables.
  3. Ensure the client endpoint URL matches the server's listening address. For example, if the server uses 'https://localhost:5001', the client should set 'new GrpcChannel.ForAddress("https://localhost:5001")'. Use DNS resolution with 'nslookup server.example.com' to verify IP.

Dead Ends

Common approaches that don't work:

  1. Increasing the deadline or timeout in the gRPC call 95% fail

    The server is not responding at all; a longer timeout only delays the failure but does not establish a connection.

  2. Disabling SSL/TLS on the client side 80% fail

    If the server requires HTTPS, disabling TLS will cause a different error (e.g., protocol mismatch), not fix the connection refusal.

  3. Changing the port number arbitrarily 90% fail

    Unless the correct port is used, the connection will still be refused; this is a guess rather than a fix.