Fluidsynth service not starting on boot

So I followed this guide on how to set up Fluidsynth, and the only step that does not work is having it automatically start at bootup. When I log in, I find that the service is not running, and using the command fluidsynth -is gives me the following input:

FluidSynth runtime version 2.3.5
Copyright (C) 2000-2024 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.

fluidsynth: error: Failed to bind server socket: 98
Failed to create the server.
Continuing without it.
fluidsynth: warning: Failed to set thread to high priority
fluidsynth: warning: Failed to set thread to high priority

In order to have it working again, I’d have to disable and then enable back the service via systemctl. Just running systemctl enable without disabling first will not work.

Is there anything I’m missing from the guide? I’m using standard Fedora 40, KDE spin. I use Fluidsynth for general MIDI playback in DOSBox and old Windows games.

What do you get for:
systemctl status --user fluidsynth
journalctl --no-hostname -b -u fluidsynth

1 Like

First one gives:

â—Ź fluidsynth.service - FluidSynth Daemon
     Loaded: loaded (/usr/lib/systemd/user/fluidsynth.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/user/service.d
             └─10-timeout-abort.conf
     Active: active (running) since Sun 2024-09-08 11:27:07 -03; 29min ago
       Docs: man:fluidsynth(1)
   Main PID: 8659 (fluidsynth)
      Tasks: 22 (limit: 38292)
     Memory: 160.2M (peak: 162.4M)
        CPU: 22.992s
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/fluidsynth.service
             └─8659 /usr/bin/fluidsynth -is /usr/share/soundfonts/default.sf2

set 08 11:27:07 dogstation systemd[1779]: Starting fluidsynth.service - FluidSynth Daemon...
set 08 11:27:07 dogstation (uidsynth)[8659]: fluidsynth.service: Referenced but unset environment variable evaluates to an empty string: OTHER_OPTS
set 08 11:27:07 dogstation systemd[1779]: Started fluidsynth.service - FluidSynth Daemon.
set 08 11:27:07 dogstation fluidsynth[8659]: fluidsynth: warning: Failed to set thread to high priority
set 08 11:27:07 dogstation fluidsynth[8659]: fluidsynth: warning: Failed to set thread to high priority

Second one gives no entries.

What does systemctl enable --now --user fluidsynth.service report?
What files do you have in ~/.config/systemd/user?

I have ~/.config/systemd/user/default.target that I use to start services
and I also see links in ~/.config/systemd/user/graphical-session.target.wants/ on some systems.
Check that fluidsynth.service is listed somewhere.

Since it’s already enabled, it will give no output. But during first time setup, it gives me:

 Created symlink /home/yellowdog/.config/systemd/user/default.target.wants/fluidsynth.service → /usr/lib/systemd/user/fluidsynth.service.

What files do you have in ~/.config/systemd/user?

Only one directory named default.target.wants, and inside it has a symlink fluidsynth.service, which is linked to /usr/lib/systemd/user/fluidsynth.service.

The contents of this service file:

Unit]
Description=FluidSynth Daemon
Documentation=man:fluidsynth(1)
After=sound.target
After=pipewire.service

[Service]
# added automatically, for details please see
# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort
ProtectSystem=full
ProtectHome=read-only
ProtectHostname=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectKernelLogs=true
ProtectControlGroups=true
# end of automatic additions
# required in order for the above sandboxing options to work on a user unit
PrivateUsers=yes
Type=notify
NotifyAccess=main
EnvironmentFile=/etc/sysconfig/fluidsynth
EnvironmentFile=-%h/.config/fluidsynth
ExecStart=/usr/bin/fluidsynth -is $OTHER_OPTS $SOUND_FONT

[Install]
WantedBy=default.target

Given that config I would expect fluidsynth to start when you login.

Try rebooting and then login. Check systemctl --user status fluidsynth.service what does it report?

It reports the following:

â—Ź fluidsynth.service - FluidSynth Daemon
â—Ź fluidsynth.service - FluidSynth Daemon
â—Ź fluidsynth.service - FluidSynth Daemon
â—Ź fluidsynth.service - FluidSynth Daemon
â—Ź fluidsynth.service - FluidSynth Daemon
â—Ź fluidsynth.service - FluidSynth Daemon
â—Ź fluidsynth.service - FluidSynth Daemon
â—Ź fluidsynth.service - FluidSynth Daemon
â—Ź fluidsynth.service - FluidSynth Daemon
     Loaded: loaded (/usr/lib/systemd/user/fluidsynth.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/user/service.d
             └─10-timeout-abort.conf
     Active: active (running) since Sun 2024-09-08 18:27:32 -03; 41s ago
       Docs: man:fluidsynth(1)
   Main PID: 1800 (fluidsynth)
      Tasks: 18 (limit: 38292)
     Memory: 306.4M (peak: 307.4M)
        CPU: 271ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/fluidsynth.service
             └─1800 /usr/bin/fluidsynth -is /usr/share/soundfonts/default.sf2

set 08 18:27:32 dogstation systemd[1772]: Starting fluidsynth.service - FluidSynth Daemon...
set 08 18:27:32 dogstation (uidsynth)[1800]: fluidsynth.service: Referenced but unset environment variable evaluates t>
set 08 18:27:32 dogstation fluidsynth[1800]: fluidsynth: warning: Failed to set thread to high priority
set 08 18:27:32 dogstation systemd[1772]: Started fluidsynth.service - FluidSynth Daemon.
set 08 18:27:32 dogstation fluidsynth[1800]: fluidsynth: warning: Audio device hardware configuration failed
set 08 18:27:32 dogstation fluidsynth[1800]: fluidsynth: warning: Audio device hardware configuration failed
set 08 18:27:32 dogstation fluidsynth[1800]: fluidsynth: error: Failed to find an audio format supported by alsa
set 08 18:27:32 dogstation fluidsynth[1800]: Failed to create the audio driver. Giving up.


Ok then its working.

What about the last four lines there? And if it’s working, why isn’t Fluidsynth playing back on applications that use it, like DOSBox?

Oh sorry i missed the errors.

Maybe the service is starting before pipewire is ready?
You could add a After=pipewire.service to the fluidsynth.service.

A quick test would be to restart fluidsynth.service after you login and see if it starts, if so try adding the After=.

After=pipewire.service is already included in fluidsynth.service file. I posted the contents up there.

I ran into an odd issue on FreeBSD with Doomsday Engine and SDL_mixer for Music where I had to force a Soundfont:

SDL_SOUNDFONTS='/usr/local/share/sounds/sf2/FluidR3_GM.sf2' doomsday

Not too sure why I had to mess with that or why it worked, but it did :stuck_out_tongue:

This might not be exactly related with Soundfonts, but forcing the device through SDL or another env might be an idea.

Since I couldn’t find out what exactly is the problem, I ended up going the dirty route of making a very simple shell script that basically restarts the service on login:

#!/bin/bash
# this will restart fluidsynth.service after boot up
systemctl restart --now --user fluidsynth.service

It works so far, so I’m gonna call it a solution, unless there’s a good reason not to do this (I’m not an expert Linux user).