1. Create a new environment
Start by creating a new environment completely isolated from production but with the same data for debugging:2. Get access
- Remote
- Local
Access your app container via SSH:
3. Run your app in inspect mode
- Remote
- Local
Stop the current process and restart it in inspect mode:
<START_FILE> with the file defined for your app’s start command.
You get output something like this:
4. (If debugging remotely) Forward the debugger port locally
In another terminal, create an SSH tunnel that forwards to the 9229 port:5. Connect the debugger
You can now connect the debugger as if you were debugging a local application. See examples with some common tools:- Using Chrome developer tools
- Using Visual Studio Code
Go to
chrome://inspect.
Find your running app under the Remote Target list.
Click inspect to start the debugger.- Remote
- Local
In the JavaScript files from your remote site:
On the Run and Debug tab under Loaded Scripts find
Attach: Remote Process > /app.Other issues
pm2 process manager blocks other processes
If you’re using thepm2 process manager to start your app from a script,
you might find it daemonizes itself and blocks other processes (such as backups) by constantly respawning.
This may happen even if you use the --no-daemon flag.
Instead of using a script, call pm2 start directly in your start command.