Use it to steer which uplink forwards, or to explain why a slower path is used.
Path Cost
Path cost is the STP cost of a port, based on its speed. The root path cost is the sum of the port costs from a switch to the root, and decides root and designated ports.
1. show spanning-tree summary | include Pathcost — short or long method?
2. show spanning-tree vlan <id> — Cost per port and Root cost.
3. Add the costs along each path to the root — which is lowest?
4. Adjust with spanning-tree vlan <id> cost <n> on the port.
5. Same method on all switches?
port speed → port cost (short or long method) → costs summed towards the root → lowest root path cost decides root and designated ports
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
spanning-tree vlan <vlan-list> cost <cost>Primary Commands
Configuration and operational commands for this Topic.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational verification and known-good state Verify boundary
Verify the exact root bridge first; comparing costs while the root itself is wrong leads to false conclusions. For each candidate uplink, read the received/root path information and local port cost, then calculate why the selected root port is superior. Check whether cost is default or explicitly configured and whether the platform uses the expected path-cost method. When two paths have equal cost, continue through the documented bridge/port tie-breakers rather than calling the result random. After identifying the selected forwarding uplink, verify MAC learning and traffic actually follow the expected tree. This section is authored reference guidance for Path Cost in the STP context.
Step 2 Verification & troubleshooting Narrow the fault
Use show spanning-tree vlan <vlan> / interface detail to compare port cost and resulting root path cost before and after tuning.
Step 3 Failure signatures and troubleshooting branches Narrow the fault
If STP chooses the “wrong” uplink, determine whether it is actually lower cost due to a speed change, manual cost, Port-Channel state or upstream topology. If costs are equal, inspect upstream sender bridge ID and port ID. If cost changes repeatedly, correlate with link/member flaps and Port-Channel membership. If the STP tree is correct but application traffic uses another Layer-3 path, do not tune STP to solve an IP-routing problem. Avoid globally changing bridge priorities or costs when one bounded interface/instance explains the path selection. This section is authored reference guidance for Path Cost in the STP context.
Step 4 When the problem is really fixed Narrow the fault
Closure means the intended root port and alternate path remain stable with the designed path cost after convergence and during a controlled failover/recovery if redundancy is part of the objective. Replay representative Layer-2 traffic and confirm MAC learning follows the resulting tree. Check another VLAN or instance sharing the physical links to make sure a local cost change did not unintentionally shift its topology. Document actual observed cost/state separately from this reference guidance. This section is authored reference guidance for Path Cost in the STP context.
Step 5 Common mistakes Narrow the fault
- Mixing short and long path cost methods between switches.
- Unequal costs on parallel links.
Short method (default on older IOS): 10 Mb/s = 100, 100 Mb/s = 19, 1 Gb/s = 4, 10 Gb/s = 2. Long method (spanning-tree pathcost method long) scales to faster links: 1 Gb/s = 20 000, 10 Gb/s = 2 000. Use the same method on every switch. An EtherChannel's cost depends on its bandwidth.
show spanning-tree vlan <id>— root ID, local bridge ID, and each port's role, state and cost.show spanning-tree root— the root bridge, root cost and root port per VLAN.show spanning-tree vlan <id> detail— BPDUs sent and received, topology changes and their source.show spanning-tree summary— mode, enabled features and port counts per state.show spanning-tree inconsistentports— ports blocked by root guard, loop guard or type inconsistency.
ReferenceWhat it is1 section · depth on demand
What it is
STP path cost is the metric used to prefer lower-cost paths toward the root. Interface speed maps to default cost values under the active cost method.
ReferenceWhy it matters1 section · depth on demand
Why it matters
Use cost to influence or explain root-port and designated-port selection without changing the root bridge itself.
ReferenceImportant terms & boundaries4 sections · depth on demand
Key points
Lower accumulated root path cost is preferred. Manually changing cost can alter the active Layer 2 path and should be documented.
In depth
Path cost: the value STP adds up to find the best way to the root
Each port has a cost. The root path cost is the sum of the costs of the receiving ports along the path. The Catalyst 9300 guide states that cost is derived from media speed and that the short method is the default, with values of 100 (10 Mb/s), 19 (100 Mb/s), 4 (1 Gb/s), 2 (10 Gb/s) and 1 (25 or 40 Gb/s).
| Speed | Short (default) | Long (pathcost method long) |
|---|---|---|
| 10 Mb/s | 100 | 2,000,000 |
| 100 Mb/s | 19 | 200,000 |
| 1 Gb/s | 4 | 20,000 |
| 10 Gb/s | 2 | 2,000 |
| 25/40 Gb/s | 1 | 800 / 500 |
| 100 Gb/s | 1 | 200 |
With the short method, 25, 40 and 100 Gb/s links all have cost 1, so STP can't tell them apart. The long method keeps the differences.
C9300(config)# spanning-tree pathcost method long
C9300(config)# interface Te1/1/2
C9300(config-if)# spanning-tree vlan 20 cost 4000
C9300# show spanning-tree pathcost method
Spanning tree default pathcost method used is long
C9300# show spanning-tree interface Te1/1/2
Rules
| Rule | Reason |
|---|---|
| Use the same method on all switches | Mixed methods give inconsistent path choices |
| Set costs on uplinks, not access ports | Only uplinks lead to the root |
| Per-VLAN cost for load balancing | spanning-tree vlan <list> cost <n> |
| Port-channel cost | Based on bundle bandwidth; it changes when members fail |
EtherChannel side effect
A 2 × 10 Gb/s port-channel can get a lower cost than a single 10 Gb/s link. If a member fails, the cost rises and STP may move the root port. That causes a topology change in the middle of a link failure. Fix the cost on the port-channel if that behaviour isn't wanted.
Documented example, not captured output.
Quick reference
Path cost is the STP metric: each port has a cost based on its speed, and a switch's root path cost is the sum of costs along the path to the root. Lower total cost wins when choosing root ports.
| Speed | Short cost (802.1D-1998) | Long cost (802.1t) |
|---|---|---|
| 100 Mbps | 19 | 200,000 |
| 1 Gbps | 4 | 20,000 |
| 10 Gbps | 2 | 2,000 |
| 100 Gbps | — | 200 |
spanning-tree pathcost method long
interface Gi1/0/50
spanning-tree vlan 10 cost 10
Documented example, not captured output.
Use the long method in networks with 10 Gbps and faster links, and configure it consistently on all switches.
Mechanics and state ownership
Path cost gives STP a deterministic way to prefer one Layer-2 path to the root over another. A switch receives a neighbor’s advertised root path cost, adds the cost of its local receiving port and compares the resulting root information with other candidates. Lower cost wins before later tie-break fields such as upstream bridge ID and port ID. The cost associated with a link can come from standardized speed mappings or explicit configuration, and long versus short cost methods can change the numeric scale. Port-Channel links are evaluated as logical STP ports, so member state can indirectly alter the operational bandwidth/cost model depending on platform behavior. This section is authored reference guidance for Path Cost in the STP context.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Switching → STP → Spanning Tree Fundamentals → Path Cost. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.cisco.com/c/en/us/support/ios-nx-os-software/ios-xe-17/series.html · confidence 94%Quick lookup tables
Path Cost operational reference
Topic-specific bounded interpretation: known-good state, suspicious signatures and the next technical proof boundary.
| Cost decision | Known-good | Failure signature | Next boundary |
|---|---|---|---|
| Root bridge | Intended root fixed | Wrong root invalidates comparison | Bridge priority |
| Local port cost | Matches design/operational link | Unexpected override/speed | Interface config |
| Total root cost | Preferred path lower | Higher path selected | Tie-break/state |
| Equal-cost tie | Deterministic IDs decide | Assumed random behavior | Bridge/port ID |
| Forwarding path | Matches selected tree | STP correct, traffic differs | MAC/L3 path |
Deep reference
Healthy vs suspicious evidence
Field-by-field state interpretation
In show spanning-tree vlan <id>, the Cost column is each port's own path cost and the Root ID Cost is the total cost from this switch to the root. Default short costs are 19 for 100 Mbps, 4 for 1 Gbps and 2 for 10 Gbps; with spanning-tree pathcost method long they are 200000, 20000 and 2000.