Error: listen tcp 0.0.0.0:8000: bind: address already in use

Hi Guys,
I really need your help please:
I have the error below and I dont know what it means:

root@debian:~# set -a
root@debian:~# source /etc/default/loraserver
root@debian:~# loraserver
INFO[0000] starting LoRa Server band=EU_863_870 docs=“https://docs.loraserver.io/” net_id=000000 version=2.2.0
INFO[0000] setup redis connection pool url=“redis://localhost:6379”
INFO[0000] connecting to postgresql
INFO[0000] backend/gateway: connecting to mqtt broker server=“tcp://localhost:1883”
INFO[0000] no geolocation-server configured
INFO[0000] configuring join-server client ca_cert= server=“http://localhost:8003” tls_cert= tls_key=
INFO[0000] no network-controller configured
INFO[0000] applying database migrations
INFO[0000] backend/gateway: connected to mqtt server
INFO[0000] backend/gateway: subscribing to rx topic qos=0 topic=gateway/+/rx
INFO[0000] backend/gateway: subscribing to stats topic qos=0 topic=gateway/+/stats
INFO[0000] migrations applied count=0
INFO[0000] starting api server bind=“0.0.0.0:8000” ca-cert= tls-cert= tls-key=
FATA[0000] start api listener error: listen tcp 0.0.0.0:8000: bind: address already in use

root@debian:~# set -a
root@debian:~# source /etc/default/lora-app-server
root@debian:~# lora-app-server
INFO[0000] starting LoRa App Server docs=“https://www.loraserver.io/” version=2.2.0
INFO[0000] connecting to postgresql
INFO[0000] setup redis connection pool
INFO[0000] handler/mqtt: TLS config is empty
INFO[0000] handler/mqtt: connecting to mqtt broker server=“tcp://localhost:1883”
INFO[0000] handler/mqtt: connected to mqtt broker
INFO[0000] handler/mqtt: subscribing to tx topic qos=0 topic=application/+/device/+/tx
INFO[0000] applying database migrations
INFO[0000] migrations applied count=0
INFO[0000] starting application-server api bind=“0.0.0.0:8001” ca-cert= tls-cert= tls-key=
FATA[0000] start application-server api listener error: listen tcp 0.0.0.0:8001: bind: address already in use

root@debian:~# set -a
root@debian:~# source /etc/default/lora-gateway-bridge
bash: /etc/default/lora-gateway-bridge: No such file or directory

I also checked the port and the results are below:

root@debian:~# lsof -Pnl +M -i4
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
avahi-dae 447 115 12u IPv4 13158 0t0 UDP *:5353
avahi-dae 447 115 14u IPv4 13160 0t0 UDP *:51307
dhclient 551 0 6u IPv4 13896 0t0 UDP *:68
minissdpd 620 0 4u IPv4 14637 0t0 UDP *:1900
firefox-e 2118 1000 68u IPv4 8828056 0t0 TCP 192.168.200.11:51148->216.58.204.46:443 (ESTABLISHED)
firefox-e 2118 1000 82u IPv4 8823269 0t0 TCP 192.168.200.11:37732->174.138.99.199:443 (ESTABLISHED)
firefox-e 2118 1000 85u IPv4 8825667 0t0 TCP 192.168.200.11:43560->52.29.202.17:443 (ESTABLISHED)
firefox-e 2118 1000 86u IPv4 8825679 0t0 TCP 192.168.200.11:43926->216.58.204.42:443 (ESTABLISHED)
firefox-e 2118 1000 87u IPv4 8828119 0t0 TCP 192.168.200.11:48006->93.184.220.29:80 (ESTABLISHED)
firefox-e 2118 1000 89u IPv4 8825664 0t0 TCP 192.168.200.11:43236->173.241.240.143:443 (ESTABLISHED)
firefox-e 2118 1000 90u IPv4 8826691 0t0 TCP 192.168.200.11:48004->93.184.220.29:80 (ESTABLISHED)
firefox-e 2118 1000 91u IPv4 8826912 0t0 TCP 192.168.200.11:43934->216.58.204.2:443 (ESTABLISHED)
firefox-e 2118 1000 92u IPv4 8823579 0t0 TCP 192.168.200.11:43890->216.58.204.2:443 (ESTABLISHED)
firefox-e 2118 1000 93u IPv4 8827574 0t0 TCP 192.168.200.11:53782->35.156.66.119:443 (ESTABLISHED)
firefox-e 2118 1000 94u IPv4 8827577 0t0 TCP 192.168.200.11:53230->34.202.97.133:443 (ESTABLISHED)
firefox-e 2118 1000 95u IPv4 8828166 0t0 TCP 192.168.200.11:48022->93.184.220.29:80 (ESTABLISHED)
firefox-e 2118 1000 96u IPv4 8825114 0t0 TCP 192.168.200.11:50908->216.58.204.46:443 (ESTABLISHED)
firefox-e 2118 1000 99u IPv4 8828167 0t0 TCP 192.168.200.11:48024->93.184.220.29:80 (ESTABLISHED)
firefox-e 2118 1000 100u IPv4 8826087 0t0 TCP 192.168.200.11:49792->216.58.204.33:443 (ESTABLISHED)
firefox-e 2118 1000 101u IPv4 8826975 0t0 TCP 192.168.200.11:48848->216.58.204.38:443 (ESTABLISHED)
firefox-e 2118 1000 102u IPv4 8826093 0t0 TCP 192.168.200.11:49428->172.217.22.132:443 (ESTABLISHED)
firefox-e 2118 1000 103u IPv4 8824400 0t0 TCP 192.168.200.11:36702->216.58.204.66:443 (ESTABLISHED)
firefox-e 2118 1000 105u IPv4 8824453 0t0 TCP 192.168.200.11:48842->216.58.204.38:443 (ESTABLISHED)
firefox-e 2118 1000 108u IPv4 8826717 0t0 TCP 192.168.200.11:54292->216.58.204.35:443 (ESTABLISHED)
firefox-e 2118 1000 112u IPv4 8824527 0t0 TCP 192.168.200.11:50902->216.58.204.46:443 (ESTABLISHED)
firefox-e 2118 1000 118u IPv4 8826976 0t0 TCP 192.168.200.11:36764->216.58.204.66:443 (ESTABLISHED)
firefox-e 2118 1000 131u IPv4 8825135 0t0 TCP 192.168.200.11:36848->216.58.204.66:443 (ESTABLISHED)
redis-ser 5385 121 4u IPv4 7661702 0t0 TCP 127.0.0.1:6379 (LISTEN)
redis-ser 5385 121 5u IPv4 8788859 0t0 TCP 127.0.0.1:6379->127.0.0.1:38068 (ESTABLISHED)
redis-ser 5385 121 6u IPv4 8792098 0t0 TCP 127.0.0.1:6379->127.0.0.1:38146 (ESTABLISHED)
redis-ser 5385 121 7u IPv4 8790900 0t0 TCP 127.0.0.1:6379->127.0.0.1:38196 (ESTABLISHED)
redis-ser 5385 121 8u IPv4 8369480 0t0 TCP 127.0.0.1:6379->127.0.0.1:47454 (ESTABLISHED)
postgres 14735 122 6u IPv4 7771769 0t0 TCP 127.0.0.1:5432 (LISTEN)
mosquitto 14770 120 5u IPv4 7771975 0t0 TCP *:1883 (LISTEN)
mosquitto 14770 120 9u IPv4 8825413 0t0 TCP 127.0.0.1:1883->127.0.0.1:35722 (ESTABLISHED)
lora-app- 14786 999 36u IPv4 8791501 0t0 TCP 127.0.0.1:38146->127.0.0.1:6379 (ESTABLISHED)
loraserve 14807 998 9u IPv4 8791428 0t0 TCP 127.0.0.1:38068->127.0.0.1:6379 (ESTABLISHED)
loraserve 14807 998 10u IPv4 8370359 0t0 TCP 127.0.0.1:47454->127.0.0.1:6379 (ESTABLISHED)
loraserve 14807 998 11u IPv4 8791597 0t0 TCP 127.0.0.1:38196->127.0.0.1:6379 (ESTABLISHED)
cupsd 17619 0 10u IPv4 8403014 0t0 TCP 127.0.0.1:631 (LISTEN)
cups-brow 17621 0 7u IPv4 8400694 0t0 UDP *:631
lora-gate 20615 997 3u IPv4 8825412 0t0 TCP 127.0.0.1:35722->127.0.0.1:1883 (ESTABLISHED)
sshd 21201 0 3u IPv4 367987 0t0 TCP *:22 (LISTEN)

Please help…
Thanks

Hi.
I have same problem.please help!

1 Like

the error message is clear - something is allready bind to your port 8000.
did you also check the ports? is another (web)service running on your server?

try to stop the lora stuff and try to connect on your port 8000 - with telnet or a webbrowser? do you get an error? can you post the output of used ports?

I have similar messages since last week after multiple months running Chirpstack on DigitalOcean Ubuntu 18 without issues. Need a little guidance to get me on my way again.

Here are the (new) error messages:
sudo chirpstack-application-server
FATA[0000] setup api error: setup application-server api error: start application-server api listener error: listen tcp 0.0.0.0:8001: bind: address already in use

sudo chirpstack-network-server
FATA[0000] setup api error: start api listener error: listen tcp 0.0.0.0:8000: bind: address already in use

Here is a list of listening ports:
sudo lsof -i -P -n | grep LISTEN
systemd-r 652 systemd-resolve 13u IPv4 15364 0t0 TCP 127.0.0.53:53 (LISTEN)
chirpstac 824 appserver 8u IPv6 19636 0t0 TCP *:8001 (LISTEN)
chirpstac 824 appserver 9u IPv6 19637 0t0 TCP *:8080 (LISTEN)
chirpstac 824 appserver 24u IPv6 19686 0t0 TCP *:8003 (LISTEN)
chirpstac 836 networkserver 8u IPv6 19616 0t0 TCP *:8000 (LISTEN)
mosquitto 881 mosquitto 4u IPv4 18973 0t0 TCP *:1883 (LISTEN)
mosquitto 881 mosquitto 5u IPv6 18974 0t0 TCP *:1883 (LISTEN)
sshd 897 root 3u IPv4 18996 0t0 TCP *:22 (LISTEN)
sshd 897 root 4u IPv6 19009 0t0 TCP *:22 (LISTEN)
redis-ser 898 redis 6u IPv4 19013 0t0 TCP 127.0.0.1:6379 (LISTEN)
redis-ser 898 redis 7u IPv6 19014 0t0 TCP [::1]:6379 (LISTEN)
postgres 936 postgres 7u IPv4 19368 0t0 TCP 127.0.0.1:5432 (LISTEN)

The chirpstack server is upgraded to the latest version.
Thank you for suggestions

Hi @Reinier

Your command to start the chirpstack networkserver fails - so out of this, there should not be a network-server process… but as i can see from your lsof command, there is a networkserver process running and listening on port 8000

you need to kill this process first. you can use

netstat -tulpn | grep :8000

this will show you something like this:

tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN XXXX/networkserver

XXXX is the process ID . kill this process with the kill command (if its not workling) use the -9 option of kill.

and then try to start again.

regards, sil

Hi @sil

Thank you for your help, much appreciated :slight_smile:
When I stop the network server, there is no output from netstat -tulpn | grep :8000

With the network server running, I can kill the process, but it looks like it just creates a new process to access the port and the “bind address already in use” error remains.

FATA[0000] setup api error: start api listener error: listen tcp 0.0.0.0:8000: bind: address already in use
root@vinduino-s-1vcpu-1gb-sfo2-01:~# netstat -tulpn | grep :8000
tcp6 0 0 :::8000 :::* LISTEN 25384/chirpstack-ne
root@vinduino-s-1vcpu-1gb-sfo2-01:~# sudo kill -9 25384
root@vinduino-s-1vcpu-1gb-sfo2-01:~# netstat -tulpn | grep :8000
tcp6 0 0 :::8000 :::* LISTEN 25498/chirpstack-ne
root@vinduino-s-1vcpu-1gb-sfo2-01:~# sudo kill -9 25498
root@vinduino-s-1vcpu-1gb-sfo2-01:~# netstat -tulpn | grep :8000
tcp6 0 0 :::8000 :::* LISTEN 25549/chirpstack-ne
root@vinduino-s-1vcpu-1gb-sfo2-01:~# sudo systemctl stop chirpstack-network-server
root@vinduino-s-1vcpu-1gb-sfo2-01:~# netstat -tulpn | grep :8000
root@vinduino-s-1vcpu-1gb-sfo2-01:~#

@hadi_keihani @Noman
Did you ever resolve this?