# Keep NGINX from crashing when config is invalid

**Project:** Servers | **Board:** Live | **Votes:** 8
**URL:** https://roadmap.ploi.io/projects/1-server-level-requests/items/409-keep-nginx-from-crashing-when-config-is-invalid

---

Sometimes it can happen that the NGINX configuration is invalid and the NGINX server is restarted with the ploi backend but crashes due to the invalid configuration. This has happened to me mostly due to errors in the LE certification process. Example:

```
$ nginx -t
nginx: [emerg] cannot load certificate "/etc/letsencrypt/live/site.test/fullchain.pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/live/site.test/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed
```

In this case the solution is simple: delete the problematic LE certificate and recreate it. However, it is not good that the nginx server is unreachable for this time, because all other sites are also unreachable.

Suggestion for a solution: Every NGINX restart should first check the configuration and output any errors instead of restarting like YOLO :)

---

## Comments

**Dennis** (2022-12-15T07:47:34+00:00):
Hi [@Morhi](/user/Morhi) ,

What I'd love to know though, is when do you want those NGINX tests to run exactly? When you manually reboot the NGINX service for example?

**Philippe Aellig** (2022-12-28T20:10:54+00:00):
Hi [@Dennis](/user/Dennis)
i tested the automatic nginx restart behavior. Nginx will restart after add domain alias and add ssl certificates.
i would love it to have the nginx config tests before these restarts and next to the manual restart button on server level.

