---
updatedAt: 2025-08-27T20:23:48.000Z
agentTools:
  projectIndex: https://documentation.bunnyshell.com/llms.txt
---

# Debugging node.js

> 📘 Debugging frontend applications is different, so please check out the dedicated [Debugging frontend apps](remote-development-debugging-frontend) section.

## Port Forwarding for node.js

We chose an application using the popular tool [nodemon](https://www.npmjs.com/package/nodemon) and an IDE from the Jetbrains suite, but the process is similar for other debugging tools and IDEs.

Debugging node.js requires the debugger to connect to the node.js server, so a (forward) port forward will be required.

The default debugger port is `9229` and we have not changed it, but if you have configured it to something else, don't forget to replace it in all steps below.

For the example below we used the node.js application from our demo-books Quickstart Guide repository: <https://github.com/bunnyshell/demo-books/tree/master/backend>

<br />

### Starting Remote Development

**Step 1. Start remote development in Bunnyshell**

You can start remote development and determine the Component using the built-in wizard, or you can specify it directly. Please see the [start documentation](remote-development-start) for more details.

Since you need a port forwarding for the `9229` port, in Bunnyshell you would write the port forward as `9229>9229`. Basically, you would need to run something similar to the command below, but replacing the Component ID with your own:

```
$ bns remote-development up --component RZmMRQX0kV --port-forward "9229>9229"
```

The local path (the one on your machine) will be requested, as the source of the code sync. It is automatically pre-filled with the current folder.

```text local shell
$ bns remote-development up --component RZmMRQX0kV --port-forward "9229>9229"
? Local Path [tab for suggestions] (/Users/myuser/playground/demo-books/backend)
```

Then, you will need to provide the path within the container, which represents the target for the code sync.

```text local shell
$ bns remote-development up --component RZmMRQX0kV --port-forward "9229>9229"
? Local Path /Users/myuser/playground/demo-books/backend
? Remote Path
```

After providing it, Bunnyshell starts to perform the Remote Development [changes within your cluster](remote-development#how-it-works): a PersistentVolumeClaim is attached to your Pod and the container's command is changed, so you can have an SSH terminal (or more) into the container and ports forwarded, as well as for the file sync to happen.

```text local shell
$ bns remote-development up --component RZmMRQX0kV --port-forward "9229>9229"
? Local Path /Users/myuser/playground/demo-books/backend
? Remote Path /usr/src/app/backend
\ Waiting for pod to be ready
```

You can provide the local path and remote path also via command parameters, `--local-sync-path` (or `-l`) and `--remote-sync-path` (or `-r`).

After the [Pod definition is changed](remote-development#how-it-works), you will be having access to the container itself through and SSH shell.

```text local shell
$ bns remote-development up --component RZmMRQX0kV --port-forward "9229>9229"
? Local Path /Users/myuser/playground/demo-books/backend
? Remote Path /usr/src/app/backend
/usr/src/app/backend #
```

Once you're in, you need to start the node.js process with debugging capabilities, so you need to include the `--inspect` flag. For us, this means running the `npm run start:dev` command, since we have it defined in the `scripts` section of `package.json`, but you could just as well run the `nodemon --inspect server.js` command.

```json package.json
...
    "scripts": {
        "start": "node server.js",
        "start:dev": "nodemon --inspect server.js"
    },
```

So, to conclude, just run:

```text container shell
$ bns remote-development up --component RZmMRQX0kV --port-forward "9229>9229"
? Local Path /Users/myuser/playground/demo-books/backend
? Remote Path /usr/src/app/backend
/usr/src/app/backend # npm run start:dev
```

You will see the output of the command, which will confirm that the debugger is listening on port `9229`

```text container shell
$ bns remote-development up --component RZmMRQX0kV --port-forward "9229>9229"
? Local Path /Users/myuser/playground/demo-books/backend
? Remote Path /usr/src/app/backend
/usr/src/app/backend # npm run start:dev

> bunnyshell-books-backend@1.0.0 start:dev
> nodemon --inspect server.js

[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node --inspect server.js`
Debugger listening on ws://127.0.0.1:9229/15efac56-c993-4473-8d1e-502f5c98d59c
For help, see: https://nodejs.org/en/docs/inspector
Server is running on port 3080.
Executing (default): CREATE TABLE IF NOT EXISTS "books" ("id"   SERIAL , "title" VARCHAR(255), "description" VARCHAR(255), "available" BOOLEAN, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id"));
...
```

<br />

### Setting up the IDE

> 📘 The information is also available in the [JetBrains Documentation](https://www.jetbrains.com/help/phpstorm/running-and-debugging-node-js.html#node_debugging_running_application).

From any Jetbrains IDE (such as IntelliJ / Webstorm / PhpStorm) menu, you would go to **Run** → **Edit Configurations**, then click on the **+** button to add a new configuration.

![](https://files.readme.io/5a3408d-node-1.png "node-1.png")

Then, choose **Attach to Node.js/Chrome**.

![](https://files.readme.io/e813c8f-node-2.png "node-2.png")

Name your configuration, make sure that the port is the correct one (if you changed it), then you need to make sure that *Chrome or Node.js > 6.3 started with --inspect* option is selected, and that the *Reconnect automatically* option is checked (so when reloading the app due to file changes you will still be able to debug).

Lastly, make sure that the folder mapping is correct, by entering the container folder in the **Remote URL** field, at the project folder level. Then click **OK**.

![](https://files.readme.io/a23becb-node-3.png "node-3.png")

To start the remote debugging process, select the configuration and hit the bug icon, **Debug**.

![](https://files.readme.io/0933ee0-node-4.png "node-4.png")

Alternately, you can do this also from the **Run** menu, by selecting the option to debug the added configuration.

![](https://files.readme.io/07a5589-node-6.png "node-6.png")

Congratulations! You are now able to remote debug your applications.

![](https://files.readme.io/748f52d-node-5.png "node-5.png")

<br />

**Congratulations!** You are now able to debug node.js applications remotely.