LoginSignup
4
4

More than 5 years have passed since last update.

別サーバにあるnodeプロセスをリモートデバッグする方法

Posted at

概要

ローカルマシンで起動したnodeプロセスのブラウザ経由のリモートデバッグはnode-inspectorを使って簡単に出来たのですが、
別マシンで起動したnodeプロセスのデバッグをしようとしたらうまく行かなかったのでその解決法を書いておきます。

ローカルマシンで起動したnodeプロセスのリモートデバッグの場合

$ node-debug -p 8888 app
(..略)
debugger listening on port 5858
Node Inspector is now available from http://127.0.0.1:8888/?ws=127.0.0.1:8888&port=5858
(..略)
# netstatで調べるとローカルアドレスが127.0.0.1でローカルからしかアクセス出来ないようです。
$ netstat -ano | grep 8888
tcp        0      0 127.0.0.1:8888              0.0.0.0:*                   LISTEN      off (0.00/0/0)

リモートマシンで起動したnodeプロセスのリモートデバッグの場合

公式ドキュメントを読んでみたところ--web-hostを付ければ、
リモートマシンのnodeプロセスに対してリモートデバッグが出来るようでした。

--web-host 0.0.0.0 Host to listen on for Node Inspector's web interface.
node-debug listens on 127.0.0.1 by default.

$ node-debug -p 8888 --web-host=0.0.0.0 app
(..略)
debugger listening on port 5858
Node Inspector is now available from http://127.0.0.1:8888/?ws=127.0.0.1:8888&port=5858
(..略)
# netstatで調べるとリモートからもアクセス出来るようになっていました。
$ netstat -ano | grep 8888
tcp        0      0 0.0.0.0:8888                0.0.0.0:*                   LISTEN      off (0.00/0/0)

参考) https://github.com/node-inspector/node-inspector

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4