ERROR_ACCESS_DENIED - 5 (0x5)

Access is denied.

Updated: Feb 21, 2026

Technical Meaning

The ERROR_ACCESS_DENIED error code indicates that the operation attempted by a process or user lacks sufficient permissions to proceed. This is a generic error message used across various Windows APIs and system operations.

Error Details

  • Error Name: ERROR_ACCESS_DENIED
  • Numeric Code: 5 (0x5)
  • Short Description: Access is denied.

This error typically occurs when the security context of the user or process does not have the necessary permissions to perform a specific operation on an object, such as a file, directory, registry key, or device.

Usage Context

The ERROR_ACCESS_DENIED can be returned by various system functions and APIs. Common scenarios include:

  • Attempting to write to a read-only file or directory.
  • Accessing a protected system resource without the appropriate privileges.
  • Executing operations that require elevated permissions, such as modifying system settings.

Developer Interpretation

When encountering ERROR_ACCESS_DENIED, developers should consider the following aspects of their application:

  • Security Context: Ensure that the process or thread has the necessary security token and access rights to perform the operation. This includes checking for appropriate user groups and permissions.
  • Operation Context: Verify that the operation being performed is valid within the context of the object in question. For example, attempting to delete a file that is currently in use by another process will likely result in this error.
  • Object Type: Different objects (files, directories, registry keys) may have different access control mechanisms and permissions. Ensure that the operation aligns with the expected behavior for the type of object being accessed.

Related Errors

  • ERROR_FILE_NOT_FOUND (2): Indicates a file or directory does not exist, which might lead to an attempt to perform operations on non-existent objects, resulting in ERROR_ACCESS_DENIED if such operations are attempted.
  • ERROR_PATH_NOT_FOUND (3): Similar to ERROR_FILE_NOT_FOUND, but for paths that do not exist. This can also result in ERROR_ACCESS_DENIED when attempting to access a path that does not exist.

FAQ

Q: Why am I getting an ERROR_ACCESS_DENIED?

A: The error typically indicates that the operation attempted lacks sufficient permissions. Check the security context and object type before retrying the operation with appropriate permissions or context.

Q: How can I resolve this issue?

A: Review the security settings of the object being accessed, ensure you have the necessary privileges, and verify that the operation is valid within the context of the object.

Summary

ERROR_ACCESS_DENIED is a generic error code indicating insufficient permissions to perform an operation. Developers should focus on ensuring proper security contexts and validating operations against the expected behavior of the objects involved.