Server could not start listening on port

Hey guys,

i moved into a new home in austria with a new UP Router. Now i wanted to get my reaspberry with homegear and openhab back and running. Unfortunately i now get the following error with homegear:

12/05/17 18:52:30.356 Loading RPC server settings from /etc/homegear/rpcservers.conf
12/05/17 18:52:30.358 Loading RPC client settings from /etc/homegear/rpcclients.conf
12/05/17 18:52:30.359 Starting Homegear...
12/05/17 18:52:30.359 Homegear version 0.7.10-1397
12/05/17 18:52:30.359 Git commit SHA of libhomegear-base: -
12/05/17 18:52:30.359 Git branch of libhomegear-base:     -
12/05/17 18:52:30.359 Git commit SHA of Homegear:         -
12/05/17 18:52:30.359 Git branch of Homegear:             -
12/05/17 18:52:30.361 Info: Setting allowed core file size to "4294967295" for user with id 0 and group with id 0.
12/05/17 18:52:30.361 Info: Core file size now is "4294967295".
12/05/17 18:52:30.361 Info: Setting maximum thread priority to "95" for user with id 0 and group with id 0.
12/05/17 18:52:30.361 Info: Maximum thread priority now is "95".
12/05/17 18:52:30.382 Info: Backing up database...
12/05/17 18:52:30.391 Can't execute "PRAGMA journal_mode=DELETE": database is locked
12/05/17 18:52:30.392 Can't execute "PRAGMA journal_mode=DELETE": database is locked
12/05/17 18:52:30.723 Initializing database...
12/05/17 18:52:30.725 Info: Loading family module mod_miscellaneous.so
12/05/17 18:52:30.729 /etc/homegear/families/miscellaneous.conf
12/05/17 18:52:30.729 Info: Loading family module mod_homematicbidcos.so
12/05/17 18:52:30.742 /etc/homegear/families/homematicbidcos.conf
12/05/17 18:52:30.743 Warning: Running as root. The authors of Homegear recommend running Homegear as user.
12/05/17 18:52:30.743 Warning: Running as root. The authors of Homegear recommend running Homegear as user.
12/05/17 18:52:30.748 Starting script engine server...
12/05/17 18:52:30.756 Initializing licensing controller...
12/05/17 18:52:30.756 Loading licensing controller data...
12/05/17 18:52:30.756 Loading devices...
12/05/17 18:52:30.756 Loading XML RPC devices...
12/05/17 18:52:31.700 Loading device 1
12/05/17 18:52:31.701 Module HomeMatic BidCoS: Info: Central address set to 0xFD43AB.
12/05/17 18:52:31.701 Module HomeMatic BidCoS: Loading peer 1
12/05/17 18:52:31.717 Module HomeMatic BidCoS: Loading peer 2
12/05/17 18:52:31.743 Module HomeMatic BidCoS: Loading peer 3
12/05/17 18:52:31.747 Module HomeMatic BidCoS: Loading peer 4
12/05/17 18:52:31.752 Loading XML RPC devices...
12/05/17 18:52:31.755 Loading device 2
12/05/17 18:52:31.756 Initializing RPC client...
12/05/17 18:52:31.756 Starting XML RPC server RPCServer1 listening on :::2001...
12/05/17 18:52:31.759 Starting XML RPC server RPCServer2 listening on :::2002, SSL enabled...
12/05/17 18:52:31.759 RPC Server (Port 2001): Error: Server could not start listening on port 2001: Address already in use
12/05/17 18:52:31.759 RPC Server (Port 2001): Error: Server could not start listening on port 2001: Address already in use
12/05/17 18:52:31.821 Starting XML RPC server RPCServer3 listening on :::2003, SSL enabled, authentication enabled...
12/05/17 18:52:31.822 RPC Server (Port 2002): Error: Server could not start listening on port 2002: Address already in use
12/05/17 18:52:31.822 RPC Server (Port 2002): Error: Server could not start listening on port 2002: Address already in use
12/05/17 18:52:31.863 Starting CLI server...
12/05/17 18:52:31.864 RPC Server (Port 2003): Error: Server could not start listening on port 2003: Address already in use
12/05/17 18:52:31.864 RPC Server (Port 2003): Error: Server could not start listening on port 2003: Address already in use
12/05/17 18:52:31.864 Initializing event handler...
12/05/17 18:52:31.864 Loading events...
12/05/17 18:52:31.865 Starting flows server...
12/05/17 18:52:31.880 Starting IPC server...
12/05/17 18:52:31.885 Start listening for packets...
12/05/17 18:52:34.286 Startup complete. Waiting for physical interfaces to connect.
12/05/17 18:52:34.286 All physical interfaces are connected now.
12/05/17 18:52:34.287 Starting UPnP server...
12/05/17 18:52:34.289 Info: UPnP server: Binding to address: 192.168.0.45
12/05/17 18:52:34.289 UPnP Server: Info: Started listening.
12/05/17 18:52:36.760 RPC Server (Port 2001): Error: Server could not start listening on port 2001: Address already in use
12/05/17 18:52:36.760 RPC Server (Port 2001): Error: Server could not start listening on port 2001: Address already in use
12/05/17 18:52:36.822 RPC Server (Port 2002): Error: Server could not start listening on port 2002: Address already in use
12/05/17 18:52:36.823 RPC Server (Port 2002): Error: Server could not start listening on port 2002: Address already in use
12/05/17 18:52:36.864 RPC Server (Port 2003): Error: Server could not start listening on port 2003: Address already in use
12/05/17 18:52:36.865 RPC Server (Port 2003): Error: Server could not start listening on port 2003: Address already in use
12/05/17 18:52:41.760 RPC Server (Port 2001): Error: Server could not start listening on port 2001: Address already in use
12/05/17 18:52:41.760 RPC Server (Port 2001): Error: Server could not start listening on port 2001: Address already in use
12/05/17 18:52:41.823 RPC Server (Port 2002): Error: Server could not start listening on port 2002: Address already in use

Do you guys have any suggestion how to fix this. Cause my openhab binding cant get the connection to homegear running anymore.

Thank you very much!

Hi @MaxBec,

it looks like you try to run homegear a second time, this time as root:

12/05/17 18:52:30.392 Can't execute "PRAGMA journal_mode=DELETE": database is locked
...
12/05/17 18:52:30.743 Warning: Running as root. The authors of Homegear recommend running Homegear as user.

Only start/stop the homegear daemon via sudo service homegear start or sudo service homegear stop

What does sudo service homegear status say?

Cheers,
p

It say:

● homegear.service - Homegear
   Loaded: loaded (/lib/systemd/system/homegear.service; enabled; vendor preset:
   Active: active (running) since Tue 2017-12-05 19:39:54 CET; 57min ago
  Process: 423 ExecStartPre=/etc/homegear/homegear-start.sh (code=exited, status
 Main PID: 617 (homegear)
   CGroup: /system.slice/homegear.service
           └─617 /usr/bin/homegear -u homegear -g homegear -p /var/run/homegear/

Dez 05 19:39:51 max-pi systemd[1]: Starting Homegear...
Dez 05 19:39:54 max-pi systemd[1]: Started Homegear.
Dez 05 19:39:56 max-pi homegear[617]: 12/05/17 19:39:56.068 Loading RPC server s
Dez 05 19:39:56 max-pi homegear[617]: 12/05/17 19:39:56.070 Loading RPC client s
lines 1-12/12 (END)

So, you see - homegear itself is running.

Could you make sure, that the ip address you are trying to connect is right?

What do you mean with checking if the ip is correct? The IP of the Raspberry?
And where can I confirm it? Is there a config file?

You have to tell something more about your configuration. Where is openhab running? Where does openhab connect to?

Maybe your Pi just got a new IP from the “new” DHCP-Server on the new router and openhab does not have the correct IP for homegear anymore?

Just thoughts…

The port error is still there… But now openhab and homegear is running.
So everything is ok :wink:

Dear all,

I have the same problem with the latest docker image. Here is a debuglevel 5:

09/26/19 19:05:50.840 Module MAX: Info: PRESS on channel 2 of peer 1 with serial number KEQ0521100 was set to 0x10.
09/26/19 19:05:50.840 Module MAX: CUNX "MaxCUN": Info: Sending (MaxCUN, WOR: no): 0B330202FD31700984770000
09/26/19 19:05:53.293 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:05:58.294 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:05:59.758 MAX packet received (MaxCUN, RSSI: 0x3E): 0C330250098477FD3170001001
09/26/19 19:05:59.759 Module MAX: Info: PRESS on channel 2 of peer 1 with serial number KEQ0521100 was set to 0x10.
09/26/19 19:05:59.759 Module MAX: CUNX "MaxCUN": Info: Sending (MaxCUN, WOR: no): 0B330202FD31700984770000
09/26/19 19:06:03.294 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:06:08.294 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:06:13.294 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:06:18.295 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:06:23.296 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:06:28.297 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:06:29.983 MAX packet received (MaxCUN, RSSI: 0x50): 0900060400000000000D
09/26/19 19:06:33.297 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:06:37.219 RPC Server (Port 2001): Info: Connection from ::ffff:192.168.20.35:48594 accepted. Client number: 2130
09/26/19 19:06:37.219 RPC Server (Port 2001): Info: RPC server client id for client number 2130 is: 297
09/26/19 19:06:37.662 MAX packet received (MaxCUN, RSSI: 0x40): 0C340250098477FD3170001000
09/26/19 19:06:37.663 Module MAX: Info: PRESS on channel 1 of peer 1 with serial number KEQ0521100 was set to 0x10.
09/26/19 19:06:37.701 Module MAX: CUNX "MaxCUN": Info: Sending (MaxCUN, WOR: no): 0B340202FD31700984770000
09/26/19 19:06:38.297 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:06:39.892 MAX packet received (MaxCUN, RSSI: 0x41): 0C350250098477FD3170001001
09/26/19 19:06:39.893 Module MAX: Info: PRESS on channel 2 of peer 1 with serial number KEQ0521100 was set to 0x10.
09/26/19 19:06:39.931 Module MAX: CUNX "MaxCUN": Info: Sending (MaxCUN, WOR: no): 0B350202FD31700984770000
09/26/19 19:06:41.613 RPC Server (Port 2001): Info: Connection from ::ffff:192.168.20.23:57600 accepted. Client number: 2137
09/26/19 19:06:41.613 RPC Server (Port 2001): Info: RPC server client id for client number 2137 is: 298
09/26/19 19:06:41.614 Web server (Port 2001): Client is requesting: /admin/maintenance/logs/view (translated to: "/var/lib/homegear/www/rpc/admin/index.php", method: POST)
09/26/19 19:06:41.614 Script Engine Server: Info: Starting script "/var/lib/homegear/admin-ui/public/index.php" with id 45.
09/26/19 19:06:41.873 Info: Script with id 45 finished with exit code 0
09/26/19 19:06:42.865 MAX packet received (MaxCUN, RSSI: 0x46): 0C350250098477FD3170001001
09/26/19 19:06:42.865 Module MAX: Info: PRESS on channel 2 of peer 1 with serial number KEQ0521100 was set to 0x10.
09/26/19 19:06:42.866 Module MAX: CUNX "MaxCUN": Info: Sending (MaxCUN, WOR: no): 0B350202FD31700984770000
09/26/19 19:06:43.298 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:06:48.298 RPC Server (Port 2000): Error: Server could not start listening on port 2000: Cannot assign requested address
09/26/19 19:06:48.866 RPC Server (Port 2001): Info: Connection from ::ffff:192.168.20.23:57604 accepted. Client number: 2142
09/26/19 19:06:48.866 RPC Server (Port 2001): Info: RPC server client id for client number 2142 is: 299
09/26/19 19:06:48.867 Web server (Port 2001): Client is requesting: /admin/maintenance/logs/view (translated to: "/var/lib/homegear/www/rpc/admin/index.php", method: POST)
09/26/19 19:06:48.867 Script Engine Server: Info: Starting script "/var/lib/homegear/admin-ui/public/index.php" with id 46.

The log gets heavily flooded. the docker homegear version is v0.7.40-2948

I tried to modify the rpcsserver configuration by adding interface = 0.0.0.0 or interface = :: to all entries - it didnt help. Probably I did something wrong.

I am running homegear together with hoem assistant both in docker on a QNAP NAS.

thanks a lot for the help!!!

Anybody who can help in getting the issue cause narrowed down? The docker image is running in bridge mode, so homegear got its own IP-address.

@see Server could not start listening on port 2000