Can’t Acquire Lock for App in DirectAdmin Node.js
Table of Contents
❌ Error: Can’t acquire lock for app (Node.js – Shared Hosting)
Applies To
- DirectAdmin Shared Hosting
- Node.js Applications
- Error example:
Can't acquire lock for app: domains/yourdomain.com/public_html/your-node-app
📌 Overview
This error occurs when a Node.js application becomes stuck in a locked state.
DirectAdmin uses a lock mechanism to manage Node.js processes. If an app crashes, restarts incorrectly, or is force-stopped, the lock file may not release automatically.
As a result, the control panel cannot start or manage the application.
This guide explains how to safely fix the issue without terminal/SSH access.
🚨 Common Reasons for This Error
- Node.js app crashed unexpectedly
- App was restarted too quickly
- Browser session closed while starting/stopping app
- Server resource limit hit
- Previous lock file not cleared automatically
✅ Solution 1: Restart the App from DirectAdmin/cPanel (Recommended First)
Step 1: Login to DirectAdmin or cPanel
- Open your hosting control panel
- Navigate to:
Account Manager → Node.js Apps
Step 2: Stop the App
- Locate your Node.js application
- Click STOP
- Even if the app already shows “Stopped”, still click STOP
Step 3: Wait
- Wait 30–60 seconds
- This allows the system to release the lock automatically
Step 4: Start the App
- Click START
✔ If the app starts successfully → Issue resolved
❌ If error persists → Proceed to Solution 2
🔥 Solution 2: Remove Lock File Manually (Most Effective)
This is the best and safest fix when terminal access is not available.
Step 1: Open File Manager
- Go to:
Account Manager → File Manager
Step 2: Enable Hidden Files
- Click Settings or Options
- Enable:
☑ Show Hidden Files (dotfiles)
Step 3: Navigate to Node.js Directory
Go to:
domains/yourdomain.com/.nodejs/
⚠️ Note: The
.nodejsfolder is hidden by default.
Step 4: Delete Lock Files
Inside the .nodejs folder, delete only the following if they exist:
lock
.lock
pid
pids/
✔ These files are safe to remove
❌ Do NOT delete other files
Step 5: Restart the App
- Go back to:
Account Manager → Node.js Apps - Click START
✅ The app should now start normally.
⚙️ Solution 3: Increase Execution Limits (Prevention)
Low execution limits can cause apps to crash and lock again.
Recommended PHP Settings
Set the following values in Select PHP Version / PHP Settings:
max_execution_time = 300
memory_limit = 512M
Where to update
Account Manager → Select PHP Version → Options
Save changes after updating.
🛡️ Optional: Add Graceful Exit Handling (Advanced)
To prevent lock issues during restarts, add this code to your Node.js app:
process.on('SIGTERM', () => {
process.exit(0);
});
process.on('SIGINT', () => {
process.exit(0);
});
This ensures the app releases locks properly when stopped by DirectAdmin.
⚠️ Important Limitations of Shared Hosting
Node.js on shared hosting has the following constraints:
- No process manager (PM2 not available)
- Limited memory & CPU
- Apps can stop unexpectedly
- Lock issues may recur under heavy load
