I have been asked to help a colleague with a web application hosted on a digital ocean droplet. The application was initially created and maintained by someone who is no longer contactable, no one really knows what the application was written in, but they now need to make some changes and would like to be able to connect to the database.
After speaking with support at digital ocean they advised me I needed to reset the root password (it was unknown) I did that this morning but now the website is offline with a gateway 502 error.
If I try to load the webpage, I get this error in the logs.
2022/09/04 21:46:48 [error] 8165#8165: *42 connect() failed (111: Connection refused) while connecting to upstream, client: 220.127.116.11, server: antifungalinteractions.org, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "antifungalinteractions.org"
If I check the status of nginx,
root@adi:/# sudo systemctl status nginx ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2022-09-04 21:16:56 UTC; 33min ago Process: 8144 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS) Process: 8160 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 8157 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 8164 (nginx) Tasks: 2 Memory: 1.9M CPU: 73ms CGroup: /system.slice/nginx.service ├─8164 nginx: master process /usr/sbin/nginx -g daemon on; master_process on └─8165 nginx: worker process Sep 04 21:16:56 adi systemd: Starting A high performance web server and a reverse proxy server... Sep 04 21:16:56 adi systemd: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument Sep 04 21:16:56 adi systemd: Started A high performance web server and a reverse proxy server.
Here I see an error regarding parsing the PID file, from some research it suggests this is a common bug caused by the systmd trying to read the file before nginx created it, and suggests the follow (which I have not done yet, as I am a total noob with this and dont want to break anything.)
Step 1. Create the directory /etc/systemd/system/nginx.service.d Create a directory named nginx.service.d in /etc/systemd/system/:
mkdir /etc/systemd/system/nginx.service.d Should the system complain that it already exists, ignore and move on to Step 2.
Step 2. Print data to file Execute:
printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf
This is a one-liner. printf will write its output into the configuration file /etc/systemd/system/nginx.service.d/override.conf.
Step 3. Reload the daemon Reload systemd manager configuration:
systemctl daemon-reload This will rerun all generators, reload all unit files and recreate the entire systemd dependency tree.
Step 4. Restart NGINX This line will restart NGINX for you:
systemctl restart nginx The error should be fixed now. Any help or suggestions on how to get the website back up and running?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.