WebSockets request was expected error when using --inspect-brk option

17,509

You can't run your web server and the debugger on the same port. They are each separate servers (the debugger is a server built into the node.js runtime).

So, you can either remove the port and host designation from the --inspect-brk option and just let it use the defaults (which is all I ever use) or you can select a different port for the debugger that doesn't conflict with your web server or anything else running on that host.

Share:
17,509

Related videos on Youtube

ycshao
Author by

ycshao

Updated on June 04, 2022

Comments

  • ycshao
    ycshao over 1 year

    When I run nodemon dist/server/app.js it works on default port 3000 and I'm able to reach my API. But if I run nodemon --inspect-brk=localhost:3000 dist/server/app.js, I got error saying "WebSockets request was expected". What's wrong?

    • jfriend00
      jfriend00 over 5 years
      Yeah, the debugger is yet another server, built into the node.js runtime.
    • ycshao
      ycshao
      @jfriend00, I think I got what you meant, --inspect-brk=localhost:3000 will try to attach debugger to the same port as the server is running. I didn't realize server and debugger are different process.
    • jfriend00
      jfriend00
      You can't run the debugger and your server on the same port. Using --inspect-brk=localhost:3000 tells it to run the debugger on port 3000 which is where your server already is. Why are you passing a port number for --inspect-brk at all?