Nginx Warning: duplicate MIME type “text/html” – Cause and Quick Fix
After enabling Gzip compression in Nginx and running a config test, you may spot a warning in the terminal or error log: nginx: [warn] duplicate MIME type "text/html". Even though Nginx still starts and serves traffic, the warning points to a redundant line in your configuration.

The reason is straightforward: Nginx compresses text/html responses automatically whenever gzip on; is enabled, so listing text/html inside gzip_types tells the server to register the same MIME type twice.
How the Warning Looks
A typical message during nginx -t or inside /var/log/nginx/error.log looks like this:
nginx: [warn] duplicate MIME type "text/html" in /etc/nginx/nginx.conf:42
How to Fix gzip_types Properly
Open the config file mentioned in the warning (usually /etc/nginx/nginx.conf or a snippet in /etc/nginx/conf.d/) and simply remove text/html from the gzip_types directive. A clean, modern Gzip block looks like this:
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
gzip_min_length 1024;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/javascript
application/json
application/xml
application/rss+xml
image/svg+xml
font/woff2;
If you are not sure which included file defines the directive, search the entire configuration directory in one command:
grep -rn "gzip_types" /etc/nginx/
Then verify the syntax and reload Nginx without dropping active connections:
nginx -t && systemctl reload nginx
A Few Extra Notes on Nginx Gzip
- HTML stays compressed: removing
text/htmlfromgzip_typesnever disables HTML compression – Nginx always includes it by default. - Check Brotli too: if you use the
ngx_brotlimodule, the same rule applies tobrotli_types(do not addtext/htmlthere either). - Avoid double definitions: if you set
gzip_typesinside bothhttp {}and a specificserver {}block, keep it in one place unless a virtual host truly needs custom rules.
Once text/html is removed from gzip_types, nginx -t finishes cleanly with zero warnings and your error log stays free of noise.