I have an nginx service and it works perfectly, the only problem is I can't enable it. I followed this thread Not a native service systemd - can't run on boot and did what was told in the accepted answer and I still have a problem.

When I run:

sudo systemctl enable nginx.service

I get:

Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx
update-rc.d: error: nginx Default-Start contains no runlevels, aborting.

When I start it with sudo systemctl start nginx.service and run:

sudo systemctl status nginx.service

I am getting:

nginx.service - The NGINX HTTP and reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-10-28 08:26:05 UTC; 57min ago
    Tasks: 3 (limit: 2303)
   CGroup: /system.slice/nginx.service
           ├─1281 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
           ├─2094 nginx: worker process
           └─2095 nginx: cache manager process

Oct 28 08:26:04 vps-cef86568 systemd[1]: Starting nginx.service...
Oct 28 08:26:05 vps-cef86568 nginx[1262]:  * Starting Nginx Server
Oct 28 08:26:05 vps-cef86568 nginx[1262]:    ...done.
Oct 28 08:26:05 vps-cef86568 systemd[1]: Started nginx.service.

My /etc/systemd/system/nginx.service file looks like this:

Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target

ExecStartPre=/usr/sbin/nginx -t
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID


Any suggestions how to enable it?

  • cat /var/log/syslog - any entries? – Berndinox Oct 28 '20 at 10:05
  • @Berndinox when I try to enable the nginx the only new line in the log is: Oct 28 10:32:07 vps-server-45123945 systemd[1]: Reloading. – Don40 Oct 28 '20 at 11:33

For some reason Ubuntu's build of nginx includes both a systemd unit and the obsolete SysV init script that it was meant to replace. This also is present in 20.04 LTS, so upgrading will not help. I would guess some packager just forgot about it; consider opening a report on Launchpad so the maintainers can remove the obsolete script.

For the immediate problem, you probably should use the systemd unit that Ubuntu shipped, rather than your own. Delete the file you created, run systemctl daemon-reload, and then try enabling the service again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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