I've installed Butterfly http terminal server, written in python, on my Arch machine. I'm new to systemd, but I'm having an issue with one of the command line parameters.

/usr/bin/butterfly.server.py --shell=/usr/fish --unsecure --host=""

This works as expected, and I can access the terminal through a web browser on another machine.

However, when I created a simple systemd .service for it:

Description=Butterfly Terminal Server

ExecStart=/usr/bin/butterfly.server.py --shell=/bin/fish --host="" --unsecure


It will not start with --host="" in the ExecStart line, and reports:

[root@ArchHP sockets.target.wants]# systemctl status butterfly.service -l
● butterfly.service - Butterfly Terminal Server
   Loaded: loaded (/usr/lib/systemd/system/butterfly.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2015-01-07 23:08:29 CST; 26s ago
  Process: 3203 ExecStart=/usr/bin/butterfly.server.py --shell=/bin/fish --host="" --unsecure (code=exited, status=1/FAILURE)
 Main PID: 3203 (code=exited, status=1/FAILURE)

Jan 07 23:08:28 ArchHP butterfly.server.py[3203]: File "/usr/lib/python3.4/site-packages/tornado/tcpserver.py", line 125, in listen
Jan 07 23:08:28 ArchHP butterfly.server.py[3203]: sockets = bind_sockets(port, address=address)
Jan 07 23:08:28 ArchHP butterfly.server.py[3203]: File "/usr/lib/python3.4/site-packages/tornado/netutil.py", line 106, in bind_sockets
Jan 07 23:08:28 ArchHP butterfly.server.py[3203]: 0, flags)):
Jan 07 23:08:28 ArchHP butterfly.server.py[3203]: File "/usr/lib/python3.4/socket.py", line 530, in getaddrinfo
Jan 07 23:08:28 ArchHP butterfly.server.py[3203]: for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
Jan 07 23:08:28 ArchHP butterfly.server.py[3203]: socket.gaierror: [Errno -2] Name or service not known
Jan 07 23:08:29 ArchHP systemd[1]: butterfly.service: main process exited, code=exited, status=1/FAILURE
Jan 07 23:08:29 ArchHP systemd[1]: Unit butterfly.service entered failed state.
Jan 07 23:08:29 ArchHP systemd[1]: butterfly.service failed.

If I then remove --host="", it will start successfully, but only be accessible on my local machine - other computers will not be granted access. I then tried to make a butterfly.socket for the service, but haven't had any success in looking up the error message.

Why is running it through ExecStart any different than running it in a command line, and how do I start it with that parameter? As a last resort, I can try modifying the python script to instead default to, but I'd like to understand why I'm getting the error with sudo systemctl restart butterfly.service but not when executing directly.

2 Answers 2


When you start butterfly from shell, it removes quotes around On the other hand, systemd doesn't do quote expansion in this situation, because it is not a shell.

Actually, systemd is capable of stripping quotes around arguments, but not in middle of them.

So, try to remove quotes around in your service file and see what changes. Do not forget to systemctl daemon-reload.

P. S.: You can't magically make a daemon socket-activatable just by writing a .socket unit. Its code must be changed to support socket activation.

  • That was exactly it, and I've abandoned the the .socket idea. Thank you!
    – Ehryk
    Jan 9, 2015 at 3:59
  • Actually, its code requires no changes in this particular instance. This is because Mounier Florian, author of butterfly, put systemd service and socket units in the package, and made it socket activatable, six months ago.
    – JdeBP
    Jan 9, 2015 at 14:46
  • @JdeBP: Ah, ok. Actually, I don't know what butterfly is, for me it's just an "abstract daemon" :) You can suggest an edit to my answer to clarify this.
    – intelfx
    Jan 9, 2015 at 22:40

I guess you have some dependencies to run your butterfly.service.While running from the command line may be all the services are up and you are not facing any problem but while starting from the systemd may be some of the dependency services are not up and before those services your butterfly.service is coming up.And try adding Restart=always to your [service] section so if it crashes it should restart itself again.

  • I'm trying to start/restart it from systemctl start butterfly.service after all other services and dependencies are loaded.
    – Ehryk
    Jan 8, 2015 at 5:56
  • What is the error are you getting when you start it using systemctl?
    – Thushi
    Jan 8, 2015 at 6:47
  • The output of systemctl status butterfly.service -l is what is shown above - socket.gaierror: [Errno -2] Name or service not known
    – Ehryk
    Jan 8, 2015 at 6:51
  • Ok..You said you tried with butterfly.socket.Can you give the contents of your butterfly.socket file?
    – Thushi
    Jan 8, 2015 at 7:02
  • @Ehryk said that he ran his service from command line when the system was already booted, so there was no chance for missed dependencies in this particular case.
    – intelfx
    Jan 8, 2015 at 8:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .