Report this

What is the reason for this report?

Python Nginx Restart Error

Posted on December 6, 2021

I’m building a web api with Flask. I got error when I use “sudo systemctl restart nginx” for ngnix restart after server installations, wsgi installations

$ sudo systemctl status nginx.servic

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 Mon 2021-12-06 09:36:31 UTC; 23h ago Docs: man:nginx(8) Process: 3210037 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Dec 06 09:36:31 systemd[1]: Starting A high performance web server and a reverse proxy server… Dec 06 09:36:31 nginx[3210037]: nginx: [emerg] unknown directive “brotli” in /etc/nginx/conf.d/brotli.conf:1 Dec 06 09:36:31 nginx[3210037]: nginx: configuration file /etc/nginx/nginx.conf test failed Dec 06 09:36:31 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE Dec 06 09:36:31 systemd[1]: nginx.service: Failed with result ‘exit-code’. Dec 06 09:36:31 systemd[1]: Failed to start A high performance web server and a reverse proxy server.

How can I solve this? I checked sites-enabled and sites-available?



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.

Paste contents of /etc/nginx/nginx.conf and /etc/nginx/conf.d/brotli.conf

Heya,

The error message says:

nginx: [emerg] unknown directive "brotli" in /etc/nginx/conf.d/brotli.conf:1

This means that NGINX does not recognize the brotli directive, which is used for Brotli compression. This can occur if the Brotli module is not installed or not properly configured in NGINX.

Here are some steps to solve this issue:

  1. Check if the Brotli module is installed: The Brotli module is not included in the standard NGINX build, and you need to install it separately. You can do this by either compiling NGINX from the source with the Brotli module or installing it via a package manager if it’s available.

  2. If the Brotli module is installed, check the NGINX configuration: Make sure that the Brotli module is correctly configured in your NGINX configuration files. It seems that your Brotli configuration is in /etc/nginx/conf.d/brotli.conf. You may want to check that file for any errors. If you don’t need Brotli compression, you could comment out the lines related to Brotli to stop the error from occurring.

  3. Check the NGINX version: Ensure that your version of NGINX supports the Brotli module. You might need to upgrade NGINX to a newer version if the current version doesn’t support Brotli.

  4. Test the NGINX configuration: After making changes to the configuration files, always run sudo nginx -t to test the configuration. This command will check your configuration for syntax errors and will help you find where the problem lies.

After you’ve resolved the issue, you can then restart NGINX with sudo systemctl restart nginx and it should start without any errors.

Remember to make backups of any configuration files before modifying them, as incorrect configurations can cause service disruptions.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.