MPD Not Working Properly despite Running as a Service

Hi, I’ve been trying to use MPD with rmpc, but it doesn’t seem to work properly, even though MPD appears to be running fine as a service. Here’s the output of systemctl status mpd:

[thomas@balian:~]$ systemctl status mpd
● mpd.service - Music Player Daemon
     Loaded: loaded (/etc/systemd/system/mpd.service; linked; preset: ignored)
    Drop-In: /nix/store/vc4rcs019vhw7n101vvz1apiqkd030ln-system-units/mpd.service.d
             └─overrides.conf
     Active: active (running) since Mon 2025-06-09 21:35:53 CEST; 5min ago
 Invocation: 648e9707eec54a33adff08ca52f6480c
TriggeredBy: ● mpd.socket
       Docs: man:mpd(1)
             man:mpd.conf(5)
    Process: 9931 ExecStartPre=/nix/store/j20lvfd7ck8p94fp93d41r3pp5gdbyi5-unit-script-mpd-pre-start/bin/mpd-pre-start (code=exited, status=0/SUCCESS)
   Main PID: 9936 (mpd)
         IP: 0B in, 0B out
         IO: 308K read, 4K written
      Tasks: 3 (limit: 18771)
     Memory: 9.6M (peak: 10M)
        CPU: 153ms
     CGroup: /system.slice/mpd.service
             └─9936 /nix/store/fznic5xxcm58azmmxshkzm3szvnaya85-mpd-0.24.4/bin/mpd --systemd /run/mpd/mpd.conf

juin 09 21:35:53 balian systemd[1]: Starting Music Player Daemon...
juin 09 21:35:53 balian mpd[9936]: zeroconf: No global port, disabling zeroconf
juin 09 21:35:53 balian systemd[1]: Started Music Player Daemon.

When I try to update the database using mpc update or directly via rmpc with the “u” key, it doesn’t seem to work. However, I can see that the PipeWire output is recognized because I can toggle it in rmpc.

Here’s my configuration.nix:

  services.mpd = {
    enable = true;
    musicDirectory = "${config.users.users.${username}.home}/Music";
    user = username;
    extraConfig = ''
      audio_output {
        type "pipewire"
        name "PipeWire Sound Server"
      }
    '';
    startWhenNeeded = true;
  };

  environment.systemPackages = with pkgs; [
    mpc
    mpd
  ];

  systemd.services.mpd.environment = {
    # https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/609
    # User-id must match above user. MPD will look inside this directory for the PipeWire socket.
    XDG_RUNTIME_DIR = "/run/user/${toString config.users.users.${username}.uid}";
  };

One thing I’ve noticed is that there is no mpd.conf generated in either /etc/mpd.conf or .config/mpd/mpd.conf.

Has anyone encountered similar issues or have suggestions on what could be going wrong?

Okay, so I found where the MPD config is generated — it’s located at /run/mpd/mpd.conf.

Here’s the config, and it seems correct:

# This file was automatically generated by NixOS. Edit mpd's configuration
# via NixOS' configuration.nix, as this file will be rewritten upon mpd's
# restart.

music_directory     "/home/thomas/Music"
playlist_directory  "/var/lib/mpd/playlists"
db_file             "/var/lib/mpd/tag_cache"

state_file          "/var/lib/mpd/state"
sticker_file        "/var/lib/mpd/sticker.sql"

bind_to_address "127.0.0.1"





audio_output {
  type "pipewire"
  name "PipeWire Sound Server"
}

However, I still can’t update the database using mpc or rmpc. Am I missing something?

I found the solution, so I’m leaving it here in case it helps someone else with the same issue.

After restarting my PC a few times, I was finally able to update and list the MPD database using:

mpc update
mpc listall

Then, I added all songs to the current playlist with mpc add /.

However, playback failed with the error:

“Failed to open ‘PipeWire Sound Server’ (pipewire); Failed to connect stream: Host is down.”

It turned out that MPD was running as a system service, but PipeWire was running as a user service. So MPD couldn’t access the PipeWire audio session.

To fix it, I moved the MPD configuration to my Home Manager setup so it would run as a user service and be able to access PipeWire directly.

Here’s the working configuration:

services.mpd = {
  enable = true;
  musicDirectory = "${config.home.homeDirectory}/Music";
  extraConfig = ''
    audio_output {
      type "pipewire"
      name "PipeWire Sound Server"
    }
  '';
};

home.packages = with pkgs; [
  mpc
];

I also removed the MPD configuration from configuration.nix, and after that, everything worked!

1 Like