What does Windows error code 1251 (ERROR_ONLY_IF_CONNECTED) mean?

 
Previous Next
ERROR_DOMAIN_CONTROLLER_EXISTS ERROR_OVERRIDE_NOCHANGES

ERROR_ONLY_IF_CONNECTED

This operation is valid only during an active server connection.

ERROR_ONLY_IF_CONNECTED is Win32 error 1251 (0x4E3). A client attempted an operation whose contract depends on a live server session, but the component was offline, disconnected, or using cached state. The code is not evidence that the server name is wrong; it first describes an invalid connection state.

Operations that commonly require live state

  • changing remote configuration that cannot be queued offline
  • querying volatile server state, locks, leases, or session properties
  • committing cached changes that require conflict detection
  • using a provider handle created before reconnect
  • performing an action after a keepalive or transport failure closed the session

What to record

Capture the connection state transition, server endpoint, session identifier, authentication status, last successful request, disconnect reason, retry count, and whether the UI displayed an offline mode. Logs should show whether the operation began before disconnection and completed afterward, because race conditions can make a connected check obsolete immediately.

Diagnostic sequence

Confirm that the transport is connected and that the higher-level session is authenticated and usable. A TCP socket can remain open while an application session has expired. Verify that the operation uses the current session object rather than a stale handle retained from an earlier connection.

Review offline and reconnect logic. If the product supports cached reads, ensure that server-only commands are disabled or explicitly queued. A generic “connected” flag shared without synchronization can allow requests through during teardown.

Recovery strategy

Re-establish the connection, rebuild session-scoped handles, authenticate again if necessary, and revalidate any data that may have changed while offline. Repeat the command only when it is idempotent or protected by a request identifier. For a user interface, preserve edits locally and explain that submission requires reconnection rather than discarding them.

Difference from network reachability codes

ERROR_HOST_DOWN says the remote system is unavailable. ERROR_NETWORK_UNREACHABLE indicates no usable route. Error 1251 can occur even after the network has recovered if the application has not rebuilt the logical server session required by the operation.

Example

A management console caches a server object, loses its WebSocket, then enables a “rotate certificate” command as soon as DNS resolution succeeds. The old session handle returns 1251. Correct reconnect logic creates a new authenticated session and refreshes server state before enabling destructive commands.

References


Looking for a different code? Search another status or error code.