21

I am trying to run a Node.js API as a service, but am running into problems.

When running systemctl status servicename.service I get the following error:

servicename.service - [Service description]  
Loaded: leaded (/etc/systemd/system/servicename.service; enabled; vendor preset: enabled)  
Active: failed (Result: start-limit-hit) since [timestamp] ago  
Process: 1142 ExecStart=/usr/bin/node /home/pi/Documents/server.js (code=exited, status=0/SUCCESS)  
Main PID: 1142 (code=exited, status=0/SUCCESS)  
[timestamp] hostname systemd[1]: servicename.service: Service hold-off time over, scheduling restart.  
[timestamp] hostname systemd[1]: Stopped [Service description]
[timestamp] hostname systemd[1]: servicename.service: Start request repeated too quickly.  
[timestamp] hostname systemd[1]: Failed to start [Service description]
[timestamp] hostname systemd[1]: servicename.service: Unit entered failed state.  
[timestamp] hostname systemd[1]: servicename.service: Failed with result 'start-limit-hit'.

What is this error and how can I resolve this issue?

I would like to run the script with sudo since part of the script needs admin permissions.

18

Probably a more correct answer:

systemctl reset-failed servicename.service

Taken from https://serverfault.com/questions/930047/how-to-bypass-systemd-start-request-repeated-too-quickly

10

Run

mkdir /var/run/sshd

then

systemctl restart ssh

:thumbsup:

DONE!

4
3

When you have start-limit-hit or Start request repeated too quickly it may be due to a Restart=on-failure directive in the service definition. Chances are, there is an initial reason for the error but it's hidden behind the one you see.

To find out: (obviously, replace carbon-relay-ng with your service)

  1. run systemctl status carbon-relay-ng
  2. find the source where the service is loaded (first image)
  3. nano /lib/systemd/system/carbon-relay-ng.service
  4. remove line Restart=on-failure and save file (second image)
  5. run systemctl restart carbon-relay-ng
  6. run systemctl status carbon-relay-ng to check real error

Find path

Open Service definition

Real error

For me it revealed the following error which I had to correct by setting the file permissions: Real error

0

I was also struggling with this same error. It happened due to the restart of the application again and again. In my scenario, my app was not running as systemd service it was running like a demon mode. Check if your application is running as demon or systemd.

1
  • You should not "need" to run your application as user "daemon" or "systemd". Instead, run your app as the user it was designed for. If running "as" daemon/systemd seemed to solve your problem, you merely found an incorrect workaround (and the true problem probably relates to permissions, see "ExecStartPre=" if I were to take a guess at your root issue) Jul 1 '20 at 15:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.