Homey App listening to a port: EADDRNOTAVAIL

I get an error ‘EADDRNOTAVAIL’ when I try to listen to a port on homey. I tried all addresses of homey (ip4,ip6), but ended up always with the same result.

error message:------------------------------------------------------------------------------------------------------------------------------ Error: listen EADDRNOTAVAIL: address not available 10.0.0.111:1025 at Server.setupListenHandle [as _listen2] (node:net:1446:21) at listenInCluster (node:net:1511:12) at doListen (node:net:1660:7) at processTicksAndRejections (node:internal/process/task_queues:84:21) Emitted ‘error’ event on Server instance at: at emitErrorNT (node:net:1490:8)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: ‘EADDRNOTAVAIL’, errno: -99, syscall: ‘listen’, address: ‘10.0.0.111’, port: 1025}
coding: ---------------------------------------------------------------------------------------------------------------------------------------
const Homey = require(‘homey’);
const net = require(‘node:net’);

// installation of a TCP/IP Server
const server = net.createServer();

class MyApp extends Homey.App {
async onInit() { // homey starts it, when app initialized
this.log(‘App has been initialized’);
// server.on(‘connection’,(sock) => { … });

 **server.listen(1025, '10.0.0.111', () => {              //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<**
      console.log('server bound',server.address());
  });// server ---- listen -------------------------------

} // ----------On Init Homey.app
}
module.exports = MyApp;


“platforms”: [ “local” ],
“category”: [ “tools” ],
“permissions”: ,

I posted it on GitHub but got no answer. Maybe somebody here has got an idea, what the reason is?

Unless Homey’s IP address is 10.0.0.111, you will get that error.

Any reason why you’re explicitly setting a host?

My homey has got this LAN-address plus a Wifi Address. Both create the error. Homey should act as the receiver of smtp messages as a server because the devices are only able to send smtp. There is no cloud necessary.

Are you running your app using homey app run or using homey app run --remote?

That doesn’t answer my question though: why are you explicitly setting a host? Not setting one will fix your issue, and it’s unrelated to cloud.

I use “homey app run”. I tried already a version without setting a host-ip, but no connection to the my homey was possible.

If you have a HP2023, that will run your app in a local Docker container (which would explain the error, since that container will not have the 10.0.0.111 address), not on your actual Homey.

Yes, that makes sense. Thank you for that hint. I am not familiar with docker containers. Is it possible to map to an external IP address?

You can try if you can access port 1025 of the machine you’re running Docker on, but I don’t know how the Homey command line tool sets up the container so it might not work.

If not, run the app directly on your Homey using homey app run --remote

Thanks a lot! You are great!!! I will test some things and I will come back hopefully with the solution. Take care!

Thanks again! “homey app run --remote” works perfect! :grinning: