Search code examples
reactjsvisual-studio-codedebuggingvscode-remote-ssh

VS Code Launch Client in Debug Mode when Remote-SSH'ing


I am using the Remote SSH plugin to load up a project on an EC2 instance. There is some port forwarding magic that the plugin is taking care of. When I try to launch the client in debug mode VS Code opens a browser with a blank page and about:blank as the address.

enter image description here

I created a launch.json file and went through basic debug steps


Solution

  • The blank page when launching the client in debug mode is caused by a mismatch between the port that Visual Studio Code is trying to connect to and the port that the client is actually listening on.

    To fix this, you need to make sure that the port that Visual Studio Code is trying to connect to is the same port that the client is listening on. You can do this by editing the launch.json file.

    To edit the launch.json file:

    1. Open the launch.json file in a text editor.
    2. Find the following line:
    "port": 9229
    
    1. Change the port number to the port that the client is listening on. For example, if the client is listening on port 8080, change the line to:
    "port": 8080
    
    1. Save the launch.json file.

    Once you have edited the launch.json file, Visual Studio Code should be able to connect to the client and start debugging.

    Here are some additional troubleshooting tips:

    • Make sure that the client is running before you try to launch it in debug mode.
    • Make sure that the port that Visual Studio Code is trying to connect to is open. You can check this by running the following command:
    netstat -ano | grep 9229
    

    If the port is open, you should see a line similar to the following:

    tcp6       0      0  :::9229     :::*          LISTEN    2002/vscode
    

    If the port is not open, you need to open it before you can start debugging. You can open the port by running the following command:

    sudo ufw allow 9229
    
    • If you are still having problems launching the client in debug mode, try restarting Visual Studio Code and the client.

    If you are still having problems, please provide more information about your project and the Remote SSH plugin that you are using.