as relevant with current times so i'm installing myself a mastodon instance...

when I try to restart nginx i get the error

root@instance-20221113-1925:/home/ubuntu# sudo systemctl restart nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.

here's the log (it says Nov 13 09:45:11 instance-20221113-1925 nginx[34044]: nginx: configuration file /etc/nginx/nginx.conf test failed):


the conf file is (unedited):


can an experienced eye spot an error? thank you!

  • found the workaround here:
    – Anton A
    Nov 13, 2022 at 10:49
  • Not a workaround. Linked configuration above is incomplete. Next time try nginx -t to get a more specific analysis of the config.
    – symcbean
    Sep 20 at 10:12

2 Answers 2


Maybe you can remove nginx first and reinstall it.

List packages installed related to nginx, and remove them.

dpkg --get-selections | grep nginx

sudo apt --purge remove nginx
sudo apt --purge remove nginx-common
sudo apt --purge remove nginx-core

And install nginx again

sudo apt install nginx

And now when I run systemctl status nginx, the service is active. successfully started nginx


Found the workaround here:
certbot instructions fail with ssl_certificate error

another addition to the instructions: at the end of IPtables setup run:

sudo iptables --flush

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .