Next.js Discord

Discord Forum

Debugging NextJS in docker container

Unanswered
Berger Picard posted this in #help-forum
Open in Discord
Avatar
Berger PicardOP
I'm basically having the exact problem mentioned here -> https://github.com/vercel/next.js/discussions/45936

I have a nextjs app running in a docker container but I cannot get the debugger to attach when using VSCode or Chrome Dev tools. When using ---inspect the debugger won't connect, and when using NODE_OPTIONS=--inspect=0.0.0.0:9229 the debugger will connect but won't stop at breakpoints. In either case I get the same error message in logs below:

NextJS 15.0.0

package.json:
"dev": "NODE_OPTIONS='--inspect' next dev",

docker-compose:
ex_web:
    ...
    entrypoint: npm run dev
    ports:
      - 3000:3000
      - 9229:9229
    expose:
      - 9229
    volumes:
      - .:/app


launch.json:
{
        "type": "node",
        "request": "attach",
        "name": "Docker: Attach to Node",
        "remoteRoot": "/app/",
        "address": "localhost",
        "localRoot": "${workspaceFolder}",
        "port": 9229,
        "sourceMaps": true,
      }


Logs:
Debugger listening on ws://0.0.0.0:9229/3ed8ecb5-4b4f-44fd-968d-f11acec86c41
For help, see: https://nodejs.org/en/docs/inspector
Starting inspector on 0.0.0.0:9229 failed: address already in use
    the --inspect option was detected, the Next.js router server should be inspected at port 9229.

0 Replies