`start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError) on boot using systemd
Closed this issue · 8 comments
Hi,
Thank you for developing pifi radio! I have similar needs and found pifi radio from musicpd.org. I have followed your installation instructions and added pifi to systemd. but i encountered this error after rebooting my raspberry pi 3
Sep 30 01:23:47 raspberrypi systemd[1]: Started A MPD web client to listen to radio. Sep 30 01:23:52 raspberrypi pifi[446]: Config found at /etc/pifi/config.json. Sep 30 01:23:54 raspberrypi pifi[446]: /var/lib/gems/2.5.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:531:in
start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
Sep 30 01:23:54 raspberrypi pifi[446]: from /var/lib/gems/2.5.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:531:in start_server' Sep 30 01:23:54 raspberrypi pifi[446]: from /var/lib/gems/2.5.0/gems/thin-1.7.2/lib/thin/backends/tcp_server.rb:16:in
connect'
Sep 30 01:23:54 raspberrypi pifi[446]: from /var/lib/gems/2.5.0/gems/thin-1.7.2/lib/thin/backends/base.rb:63:in block in start' Sep 30 01:23:54 raspberrypi pifi[446]: from /var/lib/gems/2.5.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in
run_machine'
Sep 30 01:23:54 raspberrypi pifi[446]: from /var/lib/gems/2.5.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in run' Sep 30 01:23:54 raspberrypi pifi[446]: from /var/lib/gems/2.5.0/gems/thin-1.7.2/lib/thin/backends/base.rb:73:in
start'
Sep 30 01:23:54 raspberrypi pifi[446]: from /var/lib/gems/2.5.0/gems/thin-1.7.2/lib/thin/server.rb:162:in start' Sep 30 01:23:54 raspberrypi pifi[446]: from /var/lib/gems/2.5.0/gems/rack-2.2.3/lib/rack/handler/thin.rb:22:in
run'
Sep 30 01:23:54 raspberrypi pifi[446]: from /var/lib/gems/2.5.0/gems/rack-2.2.3/lib/rack/server.rb:327:in start' Sep 30 01:23:54 raspberrypi pifi[446]: from /var/lib/gems/2.5.0/gems/pifi-0.4.9/bin/pifi:28:in
<top (required)>'
Sep 30 01:23:54 raspberrypi pifi[446]: from /usr/local/bin/pifi:23:in load' Sep 30 01:23:54 raspberrypi pifi[446]: from /usr/local/bin/pifi:23:in
Sep 30 01:23:54 raspberrypi pifi[446]: Thin web server (v1.7.2 codename Bachmanity)
Sep 30 01:23:54 raspberrypi pifi[446]: Maximum connections set to 1024
Sep 30 01:23:54 raspberrypi pifi[446]: Listening on 0.0.0.0:3000, CTRL+C to stop
Sep 30 01:23:54 raspberrypi systemd[1]: pifi.service: Main process exited, code=exited, status=1/FAILURE
Sep 30 01:23:54 raspberrypi systemd[1]: pifi.service: Failed with result 'exit-code'.
`
I have been souring the web and raking my brains but cannot find the solution. Pifi starts fine from commandline but i want it to start on boot. Next step I also want Pifi Radio to start playing the first station on the list on boot, but thats for the future.
Could you help shed some light on the above error?
TIA
neal
Hi!
Have you tried changing the port?
In /etc/systemd/system/pifi.service
, look for the line starting with ExecStart=
. Replace --port 3000
for something else, like --port 3030
.
Then, run the following:
sudo systemctl daemon-reload
sudo systemctl restart pifi
Or simply reboot.
Now check if pifi is available at http://THE.PI.IP:NEW_PORT
About playing a station on boot, this could be achieved by creating a systemd unit for calling for example mpc with the desired station.
Hi Rafael,
Thank you for replying and the suggestions! I'll give both suggestions a whirl and reply back here the outcome. cheers!
Neal
Hi Rafael,
Unfortunately just like @timomal mentioned, changing the port did not help either. Still the same error :(
I just reinstalled PiFi from scratch and used pifi.service.sample
. I can't reproduce the issue.
Oct 02 16:00:29 pi systemd[1]: Started A MPD web client to listen to radio.
Oct 02 16:00:31 pi pifi[27797]: Config found at /etc/pifi/config.json.
May I ask what OS/version are you using?
@ne4l4ng said PiFi runs successfully from the command line. So can you replace www-data
for your username? By default it should be pi
.
User=pi
Group=pi
Then, run sudo systemctl daemon-reload && sudo systemctl restart pifi
.
Hello Rafael,
I'm not very experienced with systemd.
But I think I found the problem. mpc was not running when pifi was started.
I added mpd.service
to After
in pifi.services. Now, it is working.
Here the whole file:
# Author: Rafael Cavalcanti
[Unit]
Description=A MPD web client to listen to radio
After=syslog.target network.target mpd.service
Requires=mpd.service
[Service]
Type=simple
User=www-data
Group=www-data
RuntimeDirectory=pifi
ExecStart=/usr/local/bin/pifi --port 3000
TimeoutSec=300
[Install]
WantedBy=multi-user.target
Does it make sense to you?
Thanks for implementing pifi.
Timo
Great!
It's odd to get that error message if this was the problem, but in any case it makes sense to have mpd.service
on both Requires
and After
. I'll update the sample service.
Thank you both for the report. I hope you enjoy using PiFi!