How to reliably debug a Next.js app inside Docker using VSCode (breakpoints will finally hit) #78434
Unanswered
eodeluga
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Debugging Next.js in Docker with VSCode
This guide explains how to reliably debug a Next.js app running inside a Docker container using Visual Studio Code. This was written through the experience of many hours troubleshooting with ChatGPT, only to make a simple discovery hiding in plain sight (that Next.js console was actually trying to tell me all along 😳)
🧠 Key Discovery
Next.js v15+ listens on port 9230 for its internal router debugger when started with
--inspect
.However, this port is not automatically exposed from the container. Breakpoints will not be hit unless:
9230
is explicitly mapped indocker-compose.yml
9230
, not9229
✅ Final Solution Setup
1. Expose port 9230 in Docker Compose
2. Use
package.json
script to launch the debugger properly3. VSCode
launch.json
Attach to port 9230:
4. VSCode
tasks.json
Runs the Docker environment when F5 is pressed:
5.
start-dev.sh
QOL script that builds and starts containers if not already running🔍 Verifying Debugger Is Active
Use:
You should receive a JSON response confirming the debugger is active.
Beta Was this translation helpful? Give feedback.
All reactions