# Homey Pro - Homey-API HTTPS connection fails

**URL:** <https://community.homey.app/t/homey-pro-homey-api-https-connection-fails/109043>\
**Category:** Questions & Help\
**Tags:** webapp, homey-pro\
**Created:** [April 29, 2024, 8:40am UTC](https://community.homey.app/t/homey-pro-homey-api-https-connection-fails/109043 "2024-04-29T08:40:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SePi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sepi/32/50086_2.png) [@SePi](https://community.homey.app/u/SePi)\
**Post date:** [April 29, 2024, 8:40am UTC](https://community.homey.app/t/homey-pro-homey-api-https-connection-fails/109043/1 "2024-04-29T08:40:37Z")

</div>

Hey guys,

I tested and created a working integration based on the following code snippet provided by Homey Support:

```auto
import { HomeyAPI } from 'homey-api';
const homeyApi = await HomeyAPI.createLocalAPI({
  address: 'http://192.169.1.123', // Replace this with Homey Pro's IP address
  token: 'ba78f646-4a0f-4869-95cd-c7040bc4e63b:21b9f8d2...', // Replace this with your API Key
});

// Get all devices
const devices = await homeyApi.devices.getDevices();
for(const device of Object.values(devices)) {
  console.log(device.name); // Prints the device's name
}

```

However, when I try to connect over **HTTPS** the application returns the following error:

```auto
FetchError: request to https://<homey-ip>.homey.homeylocal.com:<homey-port>/api/manager/system/ping failed, reason: getaddrinfo EAI_AGAIN <homey-ip>.homey.homeylocal.com

```

I configured my wifi router as follows:

1. Gave Homey-Pro a static IP address
2. Port forward(NAT/PAT): external `5679`, internal: `443`

NAT/PAT image of my Orange Livebox:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/0/a0d188c9a292241195c12224bf445b4f5c0e6216.png)

The only change I made to the code snippet shown above is the address:

```auto
https://<homey-ip>.homey.homeylocal.com:5679

```

_note: the Homey Support article says to use `https://192-168-0-123.homey.homeylocal.com as hostname` for HTTPS connections._

Any suggestions are much appreciated!

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [April 29, 2024, 9:01am UTC](https://community.homey.app/t/homey-pro-homey-api-https-connection-fails/109043/2 "2024-04-29T09:01:45Z")

</div>

`<homey-ip>.homey.homeylocal.com` resolves to a _local_ IP address, so you shouldn’t use the external (port-forwarded) port, just `https://<homey-ip>.homey.homeylocal.com` (unless you used your external IP address as `<homey-ip>`, but if you did that you have to make sure that your router supports hairpin NAT).

Also, if you did use your local IP address, you need to disabled DNS rebinding protection in your router, otherwise it will not accept external hostnames that resolve to internal addresses (yes, to make your local Homey connection more secure with HTTPS you need to downgrade the overall security of your network 🤷🏼‍♂️)

---

<div class="post-metadata">

**Author:** ![SePi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sepi/32/50086_2.png) [@SePi](https://community.homey.app/u/SePi)\
**Post date:** [April 29, 2024, 9:44am UTC](https://community.homey.app/t/homey-pro-homey-api-https-connection-fails/109043/3 "2024-04-29T09:44:38Z")

</div>

Thanks very much for your reply @robertklep . I tried the following:

**HTTPS** fails:

```auto
https://<local-ip>.homey.homeylocal.com
https://<local-ip>.homey.homeylocal.com:5679

https://<external-ip>.homey.homeylocal.com
https://<external-ip>.homey.homeylocal.com:5679

```

Still get the same error message, `EAI_AGAIN`…

**HTTP** works:

```auto
http://<external-ip>:5678

```

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [April 29, 2024, 10:00am UTC](https://community.homey.app/t/homey-pro-homey-api-https-connection-fails/109043/4 "2024-04-29T10:00:27Z")

</div>

Works fine for me:

```auto
const homeyApi = await HomeyAPI.createLocalAPI({
  address: 'https://192-168-23-9.homey.homeylocal.com',
  token: '...'
});

```

Can you try and resolve one of those IP-addresses from a command line or a utility to see what happens? On macOS/Linux you can do that using `host`:

```auto
$ host 192-168-23-9.homey.homeylocal.com
192-168-23-9.homey.homeylocal.com has address 192.168.23.9

```

I don’t know about Windows (perhaps use `nslookup` instead of `host`?).

---

<div class="post-metadata">

**Author:** ![SePi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sepi/32/50086_2.png) [@SePi](https://community.homey.app/u/SePi)\
**Post date:** [April 29, 2024, 10:14am UTC](https://community.homey.app/t/homey-pro-homey-api-https-connection-fails/109043/5 "2024-04-29T10:14:01Z")

</div>

I get:

```auto
yh@sepi:~$ host 192-168-0-90.homey.homeylocal.com
192-168-0-90.homey.homeylocal.com has address 192.168.0.90

```

---

<div class="post-metadata">

**Author:** ![SePi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sepi/32/50086_2.png) [@SePi](https://community.homey.app/u/SePi)\
**Post date:** [April 29, 2024, 10:24am UTC](https://community.homey.app/t/homey-pro-homey-api-https-connection-fails/109043/6 "2024-04-29T10:24:46Z")

</div>

Remarkable, I noticed the use of dashes (`-`) in the IP address when resolving in the terminal using the `$ host...`, so I tried:

```auto
https://<ext-ern-al-ip>.homey.homeylocal.com:<port>

```

_Note: use of dashes in the external ip address_

in stead of:

```auto
https://<ext.ern.al.ip>.homey.homeylocal.com:<port>

```

and it works!

> _Note to myself: Wake up and READ more closely, the Homey Support article uses dashes in `https://192-168-0-123.homey.homeylocal.com`._

Thanks a bunch for the help @robertklep!
