# How to wait for network

**URL:** <https://discourse.mopidy.com/t/how-to-wait-for-network/5713>\
**Category:** Help and support\
**Created:** [March 5, 2023, 1:00pm UTC](https://discourse.mopidy.com/t/how-to-wait-for-network/5713 "2023-03-05T13:00:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![viktak](https://avatars.discourse-cdn.com/v4/letter/v/3bc359/32.png) [@viktak](https://discourse.mopidy.com/u/viktak)\
**Post date:** [March 5, 2023, 1:00pm UTC](https://discourse.mopidy.com/t/how-to-wait-for-network/5713/1 "2023-03-05T13:00:23Z")

</div>

I have been using Mopidy on Raspberry Pis for years. Now I just installed it on a desktop machine with Debian 11. Installation went fine, Configuration is also OK. Everything is working as expected, EXCEPT, that after boot I get this in the Mopidy log:

```auto
mopidy.service - Mopidy music server
     Loaded: loaded (/lib/systemd/system/mopidy.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-03-05 14:41:12 EET; 7min ago
    Process: 388 ExecStartPre=/bin/mkdir -p /var/cache/mopidy (code=exited, status=0/SUCCESS)
    Process: 390 ExecStartPre=/bin/chown mopidy:audio /var/cache/mopidy (code=exited, status=0/SUCCESS)
   Main PID: 392 (mopidy)
      Tasks: 13 (limit: 14189)
     Memory: 64.0M
        CPU: 1.658s
     CGroup: /system.slice/mopidy.service
             └─392 /usr/bin/python3 /usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf

Mar 05 14:41:14 mcoffice mopidy[392]: INFO [YouTubeBackend-3] mopidy_youtube file caching not enabled
Mar 05 14:41:14 mcoffice mopidy[392]: INFO [YouTubeBackend-3] mopidy_youtube using jAPI
Mar 05 14:41:14 mcoffice mopidy[392]: INFO [Audio-2] mopidy.audio.actor Audio output set to "autoaudiosink"
Mar 05 14:41:14 mcoffice mopidy[392]: INFO [MainThread] mopidy.commands Starting Mopidy core
Mar 05 14:41:14 mcoffice mopidy[392]: INFO [MainThread] mopidy.commands Starting Mopidy frontends: YouTubeAutoplayer, YouTubeCoreListener, MpdFrontend, HttpFrontend
Mar 05 14:41:14 mcoffice mopidy[392]: INFO [MainThread] mopidy_mpd.actor MPD server running at [::]:6600
Mar 05 14:41:14 mcoffice mopidy[392]: ERROR [MainThread] mopidy.commands Frontend (HttpFrontend) initialization error: HTTP server startup failed: [Errno 99] Cannot assign requested address
Mar 05 14:41:14 mcoffice mopidy[392]: INFO [MainThread] mopidy.commands Starting GLib mainloop

```

This line is the error:  
`Mar 05 14:41:14 mcoffice mopidy[392]: ERROR [MainThread] mopidy.commands Frontend (HttpFrontend) initialization error: HTTP server startup failed: [Errno 99] Cannot assign requested address`

When I issue `sudo systemctl restart mopidy`, the error disappears, and the web interface is working normally. So I suspect something is not ready on the system at the time Mopidy starts.

I read it elsewhere that the service unit should have `After=network.target`, so I tried adding that to `/lib/systemd/system/mopidy.service`, but it made no difference. Also, I saw it already had several “wait for items”:

```auto
[Unit]
Description=Mopidy music server
After=avahi-daemon.service
After=dbus.service
After=network-online.target
Wants=network-online.target
After=nss-lookup.target
After=pulseaudio.service
After=remote-fs.target
After=sound.target

```

What else could be the problem?

(Note this is NOT a RPi, but a desktop PC (thin client).)

Thanks for any pointers in advance!

---

<div class="post-metadata">

**Author:** ![viktak](https://avatars.discourse-cdn.com/v4/letter/v/3bc359/32.png) [@viktak](https://discourse.mopidy.com/u/viktak)\
**Post date:** [March 5, 2023, 1:07pm UTC](https://discourse.mopidy.com/t/how-to-wait-for-network/5713/2 "2023-03-05T13:07:21Z")

</div>

I just put `Type=idle` in the unit file ([Service] section), and it works correctly after system boot. This is however, overkill. What is the specific “thing” I need to wait for?

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [March 6, 2023, 10:24am UTC](https://discourse.mopidy.com/t/how-to-wait-for-network/5713/3 "2023-03-06T10:24:14Z")

</div>

There’s good info at [NetworkTarget](https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/) about this.

On a Raspberry Pi, their “wait for network at boot” option [in raspi-config](https://github.com/RPi-Distro/raspi-config/blob/5b11405bf839083557ec64c263fc79165e01c3cd/raspi-config#L1499-L1505) solves this in a less generic way. You’d be better off reading the above systemd page, even if Kali Linux doesn’t use systemd there’s good info there.

---

<div class="post-metadata">

**Author:** ![viktak](https://avatars.discourse-cdn.com/v4/letter/v/3bc359/32.png) [@viktak](https://discourse.mopidy.com/u/viktak)\
**Post date:** [March 6, 2023, 10:51am UTC](https://discourse.mopidy.com/t/how-to-wait-for-network/5713/4 "2023-03-06T10:51:24Z")

</div>

Thank you, I’m going to do that!!

---

<div class="post-metadata">

**Author:** ![viktak](https://avatars.discourse-cdn.com/v4/letter/v/3bc359/32.png) [@viktak](https://discourse.mopidy.com/u/viktak)\
**Post date:** [March 9, 2023, 9:08am UTC](https://discourse.mopidy.com/t/how-to-wait-for-network/5713/5 "2023-03-09T09:08:23Z")

</div>

Indeed: I had to enable the `systemd-networkd-wait-online.service` service:

```auto
sudo systemctl enable systemd-networkd-wait-online.service

```

Now it works correctly

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/system/32/1_2.png) [@system](https://discourse.mopidy.com/u/system)\
**Post date:** [March 12, 2023, 9:09am UTC](https://discourse.mopidy.com/t/how-to-wait-for-network/5713/6 "2023-03-12T09:09:13Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
