# Debug app code

**URL:** <https://community.homey.app/t/debug-app-code/33516>\
**Category:** Developers\
**Created:** [August 12, 2020, 8:59am UTC](https://community.homey.app/t/debug-app-code/33516 "2020-08-12T08:59:46Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [February 14, 2023, 8:45am UTC](https://community.homey.app/t/debug-app-code/33516/17 "2023-02-14T08:45:51Z")

</div>

Another hint…if you want to debug on Homey and Docker, you can add this code to your app.js:

```auto
		if (process.env.DEBUG === '1'){
				try{ 
					require('inspector').waitForDebugger();
				}
				catch(error){
					require('inspector').open(9225, '0.0.0.0', true);
				}
		}

```

It first tries to connect to an existing debugger prozess (needed for docker) and opens a new one if not found (needed for Homey19 or Homey23 remote).

In lauch.json you can provide different profiles for Homey remote or docker connection or different settings for Homey19/23:

```auto
        {
            "type": "node",
            "request": "attach",
            "restart": true,
            "name": "Attach HA to Homey Dev",
            "address": "192.168.1.13",
            "port": 9225,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/"
        },
        {
            "type": "node",
            "request": "attach",
            "restart": true,
            "name": "Attach HA to Homey Pro 23 Wifi",
            "address": "192.168.1.15",
            "port": 9225,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/app/"
        },
        {
            "type": "node",
            "request": "attach",
            "restart": true,
            "name": "Attach HA to Homey23 Docker",
            "address": "192.168.1.15",
            "port": 9229,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/app/"
        }

```

---

_[View the full topic](https://community.homey.app/t/debug-app-code/33516)._
