Troubleshooting Guide: SQL Server Error 4861 – Bulk Load File Access Failure
Why This Error Happens
Error 4861 occurs when the SQL Server service account lacks the necessary NTFS permissions to access the source file specified in a BULK INSERT, OPENROWSET(BULK...), or bcp operation. This is commonly seen when files are stored on local drives or network shares that the service account cannot reach, or when the file path is incorrect, locked by another process, or the file itself has been moved, renamed, or corrupted. Additionally, if SQL Server is running inside a container or under a restricted security context on Windows Server 2025, access to mapped drives may be blocked entirely due to session isolation.
Step-by-Step Resolution Guide
Step 1: Identify the SQL Server Service Account
- Open SQL Server Configuration Manager and navigate to SQL Server Services.
- Note the Log On As account for the SQL Server (MSSQLSERVER) instance (e.g.,
NT Service\MSSQLSERVER, a domain account, orgMSA). - Confirm whether the account is a local service, virtual account, or domain-managed service account (gMSA), as this affects network share access.
Step 2: Grant NTFS and Share Permissions
- Right-click the target folder containing the bulk load file and select Properties > Security.
- Add the SQL Server service account identified in Step 1 and grant at least Read & Execute permissions.
- If the file resides on a network share, ensure the Share Permissions tab also includes the service account with Read access.
- Avoid using mapped drive letters (e.g.,
Z:\) in theBULK INSERTstatement since mapped drives are session-specific and not visible to Windows services; use UNC paths instead (e.g.,\\FileServer\Imports\data.csv).
Step 3: Verify File Path and Lock Status
- Confirm the exact file path and filename match what is specified in the T-SQL command, checking for typos or incorrect escape characters.
- Run
Get-Item "\\FileServer\Imports\data.csv" | Select-Object IsReadOnly, LastWriteTimein PowerShell to confirm the file exists and isn’t flagged as read-only. - Check if another process (such as an antivirus scanner or a file transfer job) has an active lock on the file using Resource Monitor > CPU tab > Associated Handles.
Step 4: Restart the SQL Server Service and Re-test
- After adjusting permissions, restart the SQL Server service via SQL Server Configuration Manager to ensure the new access token is applied.
- Re-run the
BULK INSERTorbcpcommand and monitor the SQL Server error log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for confirmation that the operation succeeded.
Alternative or Verification Steps
- To verify the fix, execute a simple test query:
BULK INSERT TestTable FROM '\\FileServer\Imports\data.csv' WITH (FIRSTROW = 2);and confirm no error 4861 is returned. - If the issue persists, copy the file locally to the SQL Server machine (e.g.,
C:\SQLImports\) and grant the service account explicit permissions there, bypassing network share complexities entirely.