Adding Network Server gives: context deadline exceeded (code: 2)

I am running a setup with all chirpstack servers on a raspberry pi cm3+ with raspbian buster lite.

I have gotten this to work before on 3 other devices. I’ve been building installation and setup script, but somewhere along the line I messed something up here. I believe it has to do with the localhost.
Everything is running. When I attempted to add a network server with localhost:8080 it fails and gives a context deadline exceeded error. However, when I changed this to 127.0.0.1:8080 it works to add it.

However, I am getting this error in the network server:
chirpstack-network-server[545]: time=“2020-06-02T18:47:05+01:00” level=error msg=“gateway: handle gateway stats error” ctx_id=140c53da-47c7-4233-b6b3-42323fbcb125 error=“get application-server client error: get application-server client error: create application-server api client error: dial application-server api error: context deadline exceeded”

I do not understand. I am completely lost at this point. I’ve tried changing some of the localhost settings in the application and network server .toml files, but this hasn’t changed anything. I do not know how to determine what “localhost” resolves to, but it apparently is not 127.0.0.1 in every situation.

Any suggestion is appreciated. I’m stuck.

Gateway is running. Is not seen by application server.

journalctl output for network-server

Blockquote
Jun 02 21:10:35 raspberrypi systemd[1]: Started ChirpStack Network Server.
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“starting ChirpStack Network Server” band=US_902_928 docs=“https://www.chirpstack.io/” net_id=000000 version=3.9.0
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“disabling all channels”
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“enabling channels” channels=“[48 49 50 51 52 53 54 55]”
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“storage: setting up storage module”
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“storage: setting up Redis client”
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“storage: connecting to PostgreSQL”
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“storage: applying PostgreSQL data migrations”
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“storage: PostgreSQL data migrations applied” count=0
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“gateway/mqtt: connecting to mqtt broker” server=“tcp://localhost:1883”
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“no geolocation-server configured”
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“configuring join-server client” ca_cert= server=“http://127.0.0.1:8003” tls_cert= tls_key=
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“backend/gateway: connected to mqtt server”
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“gateway/mqtt: subscribing to gateway event topic” qos=0 topic=gateway/+/event/+
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“api: starting network-server api server” bind=“0.0.0.0:8000” ca-cert= tls-cert= tls-key=
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“starting downlink device-queue scheduler”
Jun 02 21:10:36 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:36+01:00” level=info msg=“starting multicast scheduler”
Jun 02 21:10:53 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:53+01:00” level=info msg=“gateway/mqtt: gateway stats packet received” gateway_id=0000000000010104 stats_id=e30b61dd-2e5f-458d-aeb0-7e7bf5173913
Jun 02 21:10:53 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:53+01:00” level=info msg=“gateway updated” ctx_id=e30b61dd-2e5f-458d-aeb0-7e7bf5173913 gateway_id=0000000000010104
Jun 02 21:10:53 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:53+01:00” level=warning msg=“creating insecure application-server client” server=“localhost:8001”
Jun 02 21:10:53 raspberrypi chirpstack-network-server[13265]: time=“2020-06-02T21:10:53+01:00” level=error msg=“gateway: handle gateway stats error” ctx_id=e30b61dd-2e5f-458d-aeb0-7e7bf5173913 error=“get application-server client error: get application-server client error: create application-server api client error: dial application-server api error: context deadline exceeded”

I would stick to localhost. Looks like the issue is related to the app server api binding.