Skip to content

Torchrun errors

Torchrun manages the lifecycle of distributed PyTorch processes, handling rank assignment and initial rendezvous. When torchrun fails, it usually means the nodes could not discover each other on the network.

The most critical debugging step is isolating whether the failure is a network connectivity issue between the master and worker nodes, or a configuration mismatch in the expected world size. Always check the rendezvous endpoint first.

Working in VS Code or Remote-SSH? Diagnose your log locally with the free VS Code extension. No account or upload required for local diagnosis.

Every common torchrun error

The literal string is what you paste into a search bar, so it is the heading. “Class” is a triage category. It is not proof of ownership in your workload.

Socket listen failure

Environment / runtime
RuntimeError: The server socket has failed to listen on any local network address

The master node could not bind to the specified port for the C10d rendezvous backend. The port is either already in use by another process or the network interface is down.

First action: Run python -m torch.distributed.run to verify local syntax, check for port conflicts, and ensure the --master_addr network interface is up.

Rendezvous connection refused

Environment / runtime
ConnectionRefusedError: [Errno 111] Connection refused in rendezvous

A worker node attempted to connect to the master node for rendezvous, but the connection was actively rejected. The master may have crashed, or a firewall is blocking the port.

First action: Verify the master process is actually running before debugging network rules. Test connectivity to the --master_addr IP and port from the worker node.

Rendezvous timeout

Configuration
TimeoutError: Rendezvous timeout after 900 seconds

Not all expected nodes joined the rendezvous group before the timeout expired. The world size was configured for N nodes, but fewer than N nodes successfully connected.

First action: Count the number of active worker nodes and compare it to the --nnodes argument in your torchrun command. A node that failed to boot causes this timeout.

Errors not listed here exist. Rather than guess at their meaning, check PyTorch Elastic/Torchrun Docs, which is the authority for the strings above.

Frequently asked questions

Why does torchrun sit indefinitely without printing any errors?
Torchrun blocks while waiting for the expected number of nodes to join the rendezvous process. If one node fails to connect and the timeout is extremely high or disabled, the remaining nodes will wait forever in silence.
How do I debug a torchrun job that fails immediately upon launch?
Check the local logs for syntax errors or missing dependencies in your training script. Torchrun will tear down the entire process group if any single local rank exits with a non-zero status code during initialization.
Can I use a different rendezvous backend for torchrun?
Yes, while the default is the C10d TCP backend, you can configure torchrun to use etcd or a shared filesystem for rendezvous. This is particularly useful in environments where direct TCP connections between nodes are heavily restricted.
What is the difference between LOCAL_RANK and RANK in torchrun?
LOCAL_RANK is the index of the GPU within a single node, which you use to set the CUDA device. RANK is the global index across all nodes in the cluster, used to determine the master node and partition datasets globally.

Knowing the error is not knowing the cause

Which rank failed first, whether the checkpoint is safe to resume from, and whether this is your code or the hardware. Paste the log and Denpex answers all three, free and without an account.

Diagnose your logs free