8

I was following the tutorial https://learn.microsoft.com/en-us/aspnet/core/publishing/linuxproduction on publishing asp.net core project on Nginx, the previous steps all seem successful, but while

systemctl start kestrel-hellomvc.service
systemctl status kestrel-hellomvc.service

I got

kestrel-hellomvc.service - Example .NET Web API Application running on Ubuntu
   
Loaded: loaded (/etc/systemd/system/kestrel-hellomvc.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-04-24 03:12:42 UTC; 8s ago
Process: 4285 ExecStart=/usr/bin/dotnet /home/84999/Demo4/Demo4.dll (code=exited, status=217/USER)
Main PID: 4285 (code=exited, status=217/USER)

Apr 24 03:12:42 instance-5 systemd[1]: Started Example .NET Web API Application running on Ubuntu.
Apr 24 03:12:42 instance-5 systemd[4285]: kestrel-hellomvc.service: Failed at step USER spawning /usr/bin/dotnet: No such process
Apr 24 03:12:42 instance-5 systemd[1]: kestrel-hellomvc.service: Main process exited, code=exited, status=217/USER
Apr 24 03:12:42 instance-5 systemd[1]: kestrel-hellomvc.service: Unit entered failed state.
Apr 24 03:12:42 instance-5 systemd[1]: kestrel-hellomvc.service: Failed with result 'exit-code'.

Does anyone know the solution, it seems I don't have the /usr/bin/dotnet folder.

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90

4 Answers4

11

I've solved the problem, the source folder owner should be www-data, having 755 permission. The Apache user is called www-data on Ubuntu, and apache on CentOS. So specifically set User=www-data in kestrel-hellomvc.service if running on Ubuntu, thanks to Jeppe's comment.

Also, if you have added users in /etc/systemd/system/gunicorn.service before, removing these users might resolve this issue as well.

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
  • 2
    The Apache user is called `www-data` on Ubuntu, and `apache` on CentOS. So specifically set `User=www-data` in `kestrel-hellomvc.service` if running on Ubuntu. – Jeppe Mar 29 '19 at 19:02
  • I run on Centos, changing from `www-data` to `apache` works for me. – Trần Thanh Phong Sep 03 '22 at 03:13
9

In file /etc/systemd/system/gunicorn.service, I had added user. The issue got resolved when I removed the user.

...

[Service]
User="someuser"
...

Source: https://superuser.com/questions/1156676/what-causes-systemd-failed-at-step-user-spawning-usr-sbin-opendkim-no-such-p

SuperNova
  • 25,512
  • 7
  • 93
  • 64
3

After many hours, the answer for me was "yum reinstall systemd"

cliftonf
  • 67
  • 5
2

The same error message will be displayed if the user defined in your service file does not exist, regardless of the permission on the web app folder.

JGH
  • 15,928
  • 4
  • 31
  • 48
  • This is it! If you copy and paste generic `.service` files remember to update the `User=...` in `[Service]` section. Thanks. – Tomasz Gandor Jan 17 '18 at 10:31