RETURN CODE REFERENCE

Screeps error codes

Save and inspect the return value of every important game action. A return code identifies the first failure branch; the diagnostic paths below continue from that branch into the relevant API, object hub, guide, tool, and later-tick verification workflow.

DIAGNOSTIC NETWORK

High-frequency error paths

Start from a return code, then move through the APIs, object hubs, focused guides, tools, and accepted runtime verification already connected to that failure branch.

10 priority paths
return -9

ERR_NOT_IN_RANGE

The target exists, but the acting object does not satisfy the method's range rule. Confirm the real return code before deciding to move.

What should I check next?

  1. Confirm that the target exists and is valid for the current method.
  2. Store the action result and enter the range branch only when the real result is -9.
  3. For Creep actions, inspect the current range before deciding whether to call moveTo().
  4. Retry the original action on a later tick and verify position, Store, or target state.
return -2

ERR_NO_PATH

Movement or pathfinding could not find a usable path under the current constraints. Do not blindly repeat moveTo(); identify which path constraint failed.

What should I check next?

  1. Confirm that the target position and destination room can be resolved; cross-room work also needs valid vision and exits.
  2. Inspect walls, impassable terrain, Ramparts, and other objects that change walkability.
  3. Check range, routeCallback, roomCallback, or CostMatrix rules that may exclude every usable route.
  4. When using PathFinder directly, inspect incomplete, path, cost, and ops rather than the path array alone.
return -6

ERR_NOT_ENOUGH_RESOURCES

The current method lacks a required resource. -6 does not always mean Energy; return to the specific API and identify the missing stock, Credits, or cost.

What should I check next?

  1. Identify which API returned -6 and which resource that method actually consumes.
  2. Inspect the current Creep, Structure, room, or account stock instead of relying on planned values.
  3. Compare the requested amount with real availability, transaction cost, or recipe consumption.
  4. Retry only after the resource state changes, then store the new result to confirm the failure branch changed.
return -4

ERR_BUSY

The object is busy with an incompatible action. For Spawn workflows, inspect occupancy before deciding to queue, wait, or use another Spawn.

What should I check next?

  1. Confirm that the current API actually documents ERR_BUSY instead of borrowing rules from another method.
  2. For a Spawn, inspect spawn.spawning and whether the queue already assigned work to it.
  3. Confirm that the same tick is not submitting mutually exclusive actions to the same object.
  4. After waiting or reassigning, store the next result so a persistent failure is not mistaken for normal queueing.
return -7

ERR_INVALID_TARGET

The target exists, but it does not satisfy the method's target contract. Validate target type and state before checking range or resources.

What should I check next?

  1. Log the target and confirm it is not undefined, null, or a stale cached object.
  2. Confirm that object type, ownership, and current state satisfy this API's target contract.
  3. Separate invalid-target failures from range and capacity failures; do not hide a bad target behind moveTo().
  4. After correcting the target, store the new result and verify the action state on a later tick.
return -8

ERR_FULL

The target does not have enough remaining capacity. Inspect real free capacity and account for other same-tick actions that may reserve or change it.

What should I check next?

  1. Identify which target rejected the action and read the relevant Store or structure capacity.
  2. Use getFreeCapacity(resourceType) for the specific resource channel instead of relying on total capacity alone.
  3. Check whether other Creeps or Structures are also writing to the same target in the current tick.
  4. Recalculate a safe amount before retrying and store the new return code.
return -11

ERR_TIRED

The object cannot act again yet: a Creep may have fatigue and a Structure may still be on cooldown. Read state instead of blindly retrying.

What should I check next?

  1. For Creep movement, inspect creep.fatigue and the MOVE-to-body-weight ratio.
  2. For Structure actions, read the relevant cooldown and confirm it reached zero.
  3. Avoid repeatedly submitting the same action and flooding logs while fatigue or cooldown is clearly active.
  4. Retry after the state recovers and store the result to confirm the failure branch is gone.
return -10

ERR_INVALID_ARGS

One or more arguments do not satisfy the method contract. Log real values and check type, order, range, and option-object shape one field at a time.

What should I check next?

  1. Identify the exact call shape or overload and compare it with the current API parameter order.
  2. Log the real body, name, roomName, resourceType, amount, or opts values one by one.
  3. Check numeric ranges, string formats, array contents, and option fields for invalid values.
  4. After correcting the inputs, call once and store the result so repeated calls do not hide the original argument failure.
return -3

ERR_NAME_EXISTS

The requested Creep name is already in use. Name generation is part of the Spawn lifecycle and should be made unique before queueing or spawning.

What should I check next?

  1. Log the requested name and check whether Game.creeps[name] already exists.
  2. Confirm that the Spawn queue did not preassign the same name to multiple pending tasks.
  3. Use a predictable but unique naming strategy, such as role, sequence, and Game.time.
  4. After generating a new name, run dryRun or the real call again and store the result.
return -14

ERR_RCL_NOT_ENOUGH

The current room Controller level or structure activation state does not permit the action. Check RCL, structure limits, and isActive() before changing the plan.

What should I check next?

  1. Read room.controller?.level and confirm that the room is controlled by the Controller your code expects.
  2. For construction work, check the current RCL unlock level and structure-count limit.
  3. For existing Structures, check structure.isActive(); existence alone does not guarantee the structure can act.
  4. When RCL is insufficient, change the queue or wait for an upgrade instead of submitting a guaranteed failure every tick.
ConstantValuePractical meaningNext
OK0The command was accepted. The visible result may still appear on a later tick.—
ERR_NOT_OWNER-1The object is not controlled by you, or the method requires ownership.—
ERR_NO_PATH-2No route or path could be found under the current movement options.Diagnostic path ↑
ERR_NAME_EXISTS-3A requested name is already in use, commonly when spawning a Creep.Diagnostic path ↑
ERR_BUSY-4The object is already performing an incompatible action, such as a busy Spawn.Diagnostic path ↑
ERR_NOT_FOUND-5The requested object, resource, reaction, or state was not found.—
ERR_NOT_ENOUGH_RESOURCES-6The action lacks the specific resource required by the current method.Diagnostic path ↑
ERR_NOT_ENOUGH_ENERGY-6A legacy Energy-focused name for the same numeric result; check the current method's documented resource requirement.—
ERR_INVALID_TARGET-7The target exists but cannot be used by this method.Diagnostic path ↑
ERR_FULL-8The target store, structure, or capacity is already full.Diagnostic path ↑
ERR_NOT_IN_RANGE-9The acting object is too far from the target. Move closer and retry on a later tick.Diagnostic path ↑
ERR_INVALID_ARGS-10One or more arguments do not match the method contract.Diagnostic path ↑
ERR_TIRED-11The object is on cooldown or a Creep has fatigue.Diagnostic path ↑
ERR_NO_BODYPART-12The Creep lacks an active body part required for the action.—
ERR_RCL_NOT_ENOUGH-14The room Controller level does not permit the requested structure or action.Diagnostic path ↑
ERR_GCL_NOT_ENOUGH-15The account does not have enough control level for the requested claim or expansion.—

DEBUGGING PATTERN

Store the result once

Call the action once, save its result, log the result with context, and branch from that value. Avoid calling the same state-changing method repeatedly inside one expression.

NEXT STEP

Check the full room state

When several systems fail together, use a room snapshot to inspect workforce, Energy, Controller pressure, construction, and CPU.

Open room diagnostics →