Gunicorn is failing to start with code=exited, status=203/EXEC - python-3.x

Gunicorn works when testing with 0.0.0.0:8000 but failing with the production version below.
Tried switching user:group to myproject:myproject, root:nginx, myproject:nginx nothing working
sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2020-08-30 08:49:57 PDT; 5s ago
Process: 5576 ExecStart=/var/www/myproject/public_py/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/var/www/myproject/public_py/myproject.sock myproject.wsgi:application (code=exited, status=203/EXEC)
Main PID: 5576 (code=exited, status=203/EXEC)
Aug 30 08:49:57 myprojecthost systemd[1]: Started gunicorn daemon.
Aug 30 08:49:57 myprojecthost systemd[1]: gunicorn.service: Main process exited, code=exited, status=203/EXEC
Aug 30 08:49:57 myprojecthost systemd[1]: gunicorn.service: Failed with result 'exit-code'.
gunicorn.service
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=root
Group=nginx
WorkingDirectory=/var/www/myproject/public_py
ExecStart=/var/www/myproject/public_py/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/var/www/myproject/public_py/myproject.sock myproject.wsgi:application
[Install]
WantedBy=multi-user.target
Project lives in /var/www/myproject
cat /var/log/nginx/error.log
[crit] 1198#0: *51 connect() to unix:/var/www/myproject/public_py/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: xx.xxx.xx.xxx, server: myproject.com, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/myproject/public_py/myproject.sock:/", host: "myproject.com"
stat /var/www/myproject/public_py/env/bin/gunicorn
File: /var/www/myproject/public_py/env/bin/gunicorn
Size: 243 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 1066021 Links: 1
Access: (0775/-rwxrwxr-x) Uid: ( 0/ root) Gid: ( 984/ nginx)
Context: unconfined_u:object_r:httpd_sys_content_t:s0
Access: 2020-08-30 08:07:44.939754370 -0700
Modify: 2020-08-29 18:16:27.280494281 -0700
Change: 2020-08-30 08:46:09.047708570 -0700

SOLUTION:
nginx was being blocked via SElinux, to resolve change to permissive.

Related

what happen in rocketchat service

when I run the command
sudo systemctl enable --now rocketchat
sudo systemctl status --now rocketchat
● rocketchat.service - The Rocket.Chat server
Loaded: loaded (/lib/systemd/system/rocketchat.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-12-18 16:48:30 CST; 9s ago
Process: 30676 ExecStart=/root/.nvm/versions/node/v19.3.0/bin/node /opt/Rocket.Chat/main.js (code=exited, status=203/EXEC)
Main PID: 30676 (code=exited, status=203/EXEC)
Dec 18 16:48:30 iZbp10iedgidvzsp3ltox5Z systemd[1]: Started The Rocket.Chat server.
Dec 18 16:48:30 iZbp10iedgidvzsp3ltox5Z systemd[30676]: rocketchat.service: Failed to execute command: Permission denied
Dec 18 16:48:30 iZbp10iedgidvzsp3ltox5Z systemd[30676]: rocketchat.service: Failed at step EXEC spawning /root/.nvm/versions/node/v19.3.0/bin/node: Permission denied
Dec 18 16:48:30 iZbp10iedgidvzsp3ltox5Z systemd[1]: rocketchat.service: Main process exited, code=exited, status=203/EXEC
Dec 18 16:48:30 iZbp10iedgidvzsp3ltox5Z systemd[1]: rocketchat.service: Failed with result 'exit-code'.
I don't kown which command is denieded
-rwxrwxrwx 1 admin admin 92571400 Dec 14 19:22 /root/.nvm/versions/node/v19.3.0/bin/node*
Can you tell me how to solve this problem?

NGINX error after 'sudo systemctl status nginx' - Failed with result 'exit-code'

After trying to add new domains do my ubuntu 20.04 cloud server with nginx and pm2,I created a server block in
'/etc/nginx/sites-available/mydomain.ar'
and did the same thing into
'/etc/nginx/sites-enabled/mydomain.ar'
The next step was to do a link to both files with
ln -s /etc/nginx/sites-available/cloud.ktsoftware.ar /etc/nginx/sites-enabled/cloud.ktsoftware.ar
got a error that files already existed
ln: failed to create symbolic link '/etc/nginx/sites-enabled/mydomain.ar': File exists
in consequence i run to forced the link
sudo ln -sf /etc/nginx/sites-available/cloud.ktsoftware.ar /etc/nginx/sites-enabled/cloud.ktsoftware.ar
everything appears ok, no error response after that. Then i do
sudo systemctl status nginx
and got this error:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-07-10 13:47:17 -03; 17min ago
Docs: man:nginx(8)
Process: 1287489 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
below first error paragraph
Jul 10 13:47:17 vps-2421400-x systemd[1]: nginx.service: Succeeded.
Jul 10 13:47:17 vps-2421400-x systemd[1]: Stopped A high performance web server and a reverse proxy server.
Jul 10 13:47:17 vps-2421400-x systemd[1]: Starting A high performance web server and a reverse proxy server...
Jul 10 13:47:17 vps-2421400-x nginx[1287489]: nginx: [emerg] open() "/etc/nginx/sites-enabled/mydomain.conf" failed (2: No such file or directory) in /etc/n>
Jul 10 13:47:17 vps-2421400-x nginx[1287489]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jul 10 13:47:17 vps-2421400-x systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jul 10 13:47:17 vps-2421400-x systemd[1]: nginx.service: Failed with result 'exit-code'.
Jul 10 13:47:17 vps-2421400-x systemd[1]: Failed to start A high performance web server and a reverse proxy server.
lines 1-14/14 (END)
"lines 1-14/14 (END)" *
and crashed everything i think.
What is the best way to link the domains server blocks?

Unable to run mongoDB after installation

I'm On fedora 34 and trying to install mongoDB on this machine.
I followed installation instruction from official Docs from here. Everything installed correctly, but now i'm unable to start the service.
I executed sudo systemctl start mongod and it showed
root#fedora /v/l/mongodb [100]# systemctl start mongod
Job for mongod.service failed because the control process exited with error code.
See "systemctl status mongod.service" and "journalctl -xeu mongod.service" for details.
This is the source for mongod.service in /usr/lib/systemd/system/mongod.service
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network-online.target
Wants=network-online.target
[Service]
User=mongod
Group=mongod
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
PermissionsStartOnly=true
PIDFile=/var/run/mongodb/mongod.pid
Type=forking
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for mongod as specified in
# https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings
[Install]
WantedBy=multi-user.target
I think problem begins here
12 ExecStart=/usr/bin/mongod $OPTIONS
I'm a noob in systemd and daemons and services
This is the log from systemctl status mongod.service
root#fedora /v/l/mongodb [1]# systemctl status mongod.service
× mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2021-08-01 11:18:36 IST; 16min ago
Docs: https://docs.mongodb.org/manual
Process: 8116 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 8117 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 8118 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 8119 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
CPU: 149ms
Aug 01 11:18:36 fedora systemd[1]: Starting MongoDB Database Server...
Aug 01 11:18:36 fedora mongod[8119]: about to fork child process, waiting until server is ready for connections.
Aug 01 11:18:36 fedora mongod[8122]: forked process: 8122
Aug 01 11:18:36 fedora mongod[8119]: ERROR: child process failed, exited with 14
Aug 01 11:18:36 fedora mongod[8119]: To see additional information in this output, start without the "--fork" option.
Aug 01 11:18:36 fedora systemd[1]: mongod.service: Control process exited, code=exited, status=14/n/a
Aug 01 11:18:36 fedora systemd[1]: mongod.service: Failed with result 'exit-code'.
Aug 01 11:18:36 fedora systemd[1]: Failed to start MongoDB Database Server.
Your mongodb exited with status code 14 as systemctl status says.
Here you can find the answer

Systemd service enabled but does not start

I have a custom Spring Boot web application running on a Linux virtual machine. I have a systemd script to start/restart the application.
I have tried changing to WantedBy=default.target and it still does not work. I have tried adding After or Type and still does not work
[Unit]
Description=SpringBootSampleApp
[Service]
WorkingDirectory=/home/mecpro
ExecStop=/usr/bin/sudo /home/mecpro/webapp/webapp-0.0.1-SNAPSHOT.war
ExecStart=/usr/bin/sudo /home/mecpro/webapp/webapp-0.0.1-SNAPSHOT.war
[Install]
WantedBy=multi-user.target
My console screen looks like this
Loaded: loaded (/etc/systemd/system/webapp.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-08-12 13:26:27 UTC; 22ms ago
Main PID: 9104 (sudo)
Tasks: 2 (limit: 4675)
When I run systemctl status webapp.service, I get this
webapp.service - SpringBootSampleApp
Loaded: loaded (/etc/systemd/system/webapp.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-08-12 13:26:27 UTC; 3min 17s ago
Process: 9104 ExecStart=/usr/bin/sudo /home/mecpro/webapp/webapp-0.0.1-SNAPSHOT.war (code=exited, status=2)
Main PID: 9104 (code=exited, status=2)
Aug 12 13:26:28 x01133361 sudo[9104]: /home/mecpro/webapp/webapp-0.0.1-SNAPSHOT.war: 2: /home/mecpro/webapp/webapp-0.0.1-SNAPSHOT.war: Syntax error: "(" unexpected
Aug 12 13:26:27 x01133361 systemd[1]: Started SpringBootSampleApp.
Aug 12 13:26:27 x01133361 systemd[1]: webapp.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Aug 12 13:26:27 x01133361 systemd[1]: webapp.service: Failed with result 'exit-code'.
Aug 12 13:26:27 x01133361 sudo[9104]: root : TTY=unknown ; PWD=/home/mecpro ; USER=root ; COMMAND=/home/mecpro/webapp/webapp-0.0.1-SNAPSHOT.war
Aug 12 13:26:27 x01133361 sudo[9104]: pam_unix(sudo:session): session opened for user root by (uid=0)
Aug 12 13:26:27 x01133361 sudo[9104]: pam_unix(sudo:session): session closed for user root
This is my first question on StackOverflow so kindly excuse if the question is badly formatted. Thanks in advance.

reinstall nginx if i delete /etc/nginx in centos server how to reinstall it again i am new in centos and nginx

i install nginx in my remote server but i done some error in my nginx.conf file and could not able to revert back
so it tried to remove my nginx and reconfigure it
so i used these step which is given in the link to delete my nginx
http://www.ehowstuff.com/how-to-remove-uninstall-nginx-on-centos-7-rhel-7-oracle-linux-7/
then i use yum remove nginx and again reinstall it
but when i try sudo systemctl start nginx or [root#lotto nginx]# service nginx start
its showing
Job for nginx.service failed because the control process exitenter code hereed with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
when i am using
[root#lotto nginx]# systemctl status nginx.service
showing
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2016-07-01 07:48:44 EDT; 18s ago
Process: 30832 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
Process: 30830 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 14307 (code=exited, status=0/SUCCESS)
Jul 01 07:48:44 lotto systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jul 01 07:48:44 lotto nginx[30832]: nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:5
Jul 01 07:48:44 lotto nginx[30832]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jul 01 07:48:44 lotto systemd[1]: nginx.service: control process exited, code=exited status=1
Jul 01 07:48:44 lotto systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Jul 01 07:48:44 lotto systemd[1]: Unit nginx.service entered failed state.
Jul 01 07:48:44 lotto systemd[1]: nginx.service failed.
and [root#lotto nginx]# journalctl -xe
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2016-07-01 07:48:44 EDT; 18s ago
Process: 30832 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
Process: 30830 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 14307 (code=exited, status=0/SUCCESS)
uninstall
yum remove nginx
install
In CentOS , you should using yum install ; instead of apt-get install in Ubuntu.
at last I found out the solutions by my self
I used nginx -t which shows that I don't have any syntax error in my code
Then I use
user nobody; // in my nginx.conf
This solved my problem
Thanks everyone for your help!

Resources