# MIME type (text/html) is not supported as css

**URL:** <https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795>\
**Category:** Templates & Frontend\
**Created:** [February 12, 2023, 8:12am UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795 "2023-02-12T08:12:19Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![user712903197839871](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/user712903197839871/32/12166_2.png) [@user712903197839871](https://forum.djangoproject.com/u/user712903197839871)\
**Post date:** [February 12, 2023, 8:12am UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/1 "2023-02-12T08:12:19Z")

</div>

Hi!

When I run python manage.py runserver in terminal, I go to my site and I see in devtools error:

Refused to apply style from ‘[http://127.0.0.1:8000/csscode.css](http://127.0.0.1:8000/csscode.css)’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled.

The files are corectly linked, name in href atribute is correct. I searched all internet but I haven’t found the solution. When I open css file in browser it shows 404 error.  
I’m using Google chrome, PyCharm from jet brains, and django 4.1.5.  
Thanks beforehand and sorry for my bad english.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 12, 2023, 12:39pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/2 "2023-02-12T12:39:27Z")

</div>

This error is almost always caused by a 404 being generated by the server. The 404 returns an html page instead of the css, causing this error.

To allow us to help you resolve this, please provide the following information:

- Describe the directory structure for your project,
- Tell us what directory that `csscode.css` file is in,
- Show us the STATIC\_URL and STATICFILES\_DIRS settings from your settings.py file
- Show us the line in your template where you’re trying to load that file

(And your English is just fine - don’t worry about it!)

---

<div class="post-metadata">

**Author:** ![user712903197839871](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/user712903197839871/32/12166_2.png) [@user712903197839871](https://forum.djangoproject.com/u/user712903197839871)\
**Post date:** [February 12, 2023, 2:18pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/3 "2023-02-12T14:18:35Z")

</div>

main  
main  
| **init**.py  
| asgi.py  
| settings.py  
| urls.py  
| wsgi.py  
app  
| migrations  
| templates  
| | app  
| | | csscode.css  
| | | htmlcode.html  
| **init**.py  
| admin.py  
| apps.py  
| models.py  
| test.py  
| urls.py  
| views.py  
that’s the structure

STATIC\_URL = ‘/static/’  
STATICFILES\_DIRS is default  
\<link rel=“stylesheet” type=“text/css” href=“csscode.css”/\>

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 12, 2023, 2:26pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/4 "2023-02-12T14:26:07Z")

</div>

Couple different things here.

- CSS files are generally static files and not templates.

- You should be rendering a `static` tag url for the `href`.

Review the docs and examples at:

- [Writing your first Django app, part 6 | Django documentation | Django](https://docs.djangoproject.com/en/4.1/intro/tutorial06/)
- [How to manage static files (e.g. images, JavaScript, CSS) | Django documentation | Django](https://docs.djangoproject.com/en/4.1/howto/static-files/)

---

<div class="post-metadata">

**Author:** ![user712903197839871](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/user712903197839871/32/12166_2.png) [@user712903197839871](https://forum.djangoproject.com/u/user712903197839871)\
**Post date:** [February 12, 2023, 3:06pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/5 "2023-02-12T15:06:05Z")

</div>

main  
main  
| **init**.py  
| asgi.py  
| settings.py  
| urls.py  
| wsgi.py  
app  
| migrations  
| templates  
| | app  
| | | htmlcode.html  
| **init**.py  
| admin.py  
| apps.py  
| models.py  
| test.py  
| urls.py  
| views.py  
|staticfiles  
||csscode.css  
|static  
so now this is how structure of my project looks  
and in href atribute I’ve written:  
“{% static ‘C:/Users/Admin/PycharmProjects/site/base/staticfiles/csscode.css’%}”  
but, now server throws:  
net::ERR\_ABORTED 500 (Internal Server Error)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 12, 2023, 3:50pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/6 "2023-02-12T15:50:04Z")

</div>

Notice that in the examples in the referenced docs that they don’t specify the complete path to the file. You only specify a path relative to an entry in the STATICFILES\_DIRS setting.

---

<div class="post-metadata">

**Author:** ![user712903197839871](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/user712903197839871/32/12166_2.png) [@user712903197839871](https://forum.djangoproject.com/u/user712903197839871)\
**Post date:** [February 12, 2023, 4:36pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/7 "2023-02-12T16:36:52Z")

</div>

I had this issue for three days, I’ve searched all internet and didn’t found anything but you helped me. Massive thanks.

---

<div class="post-metadata">

**Author:** ![aimaarif](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/aimaarif/32/21563_2.png) [@aimaarif](https://forum.djangoproject.com/u/aimaarif)\
**Post date:** [May 27, 2024, 5:31pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/8 "2024-05-27T17:31:47Z")

</div>

I am also having the same issue, i am getting these three errors and i have tried many solutions on the internet but it did’nt resolved. Every link, directory structure added is correct, but still the issue persists. I am using Django 5.0.2  
These are errors shown in console.  
" 1. Verify stylesheet URLs

1. This page failed to load a stylesheet from a URL.

2. AFFECTED RESOURCES

```
1. 1 source

  1. 127.0.0.1/:17

```

Failed to load resource: the server responded with a status of 404 (Not Found)  
127.0.0.1/:1

Refused to apply style from ‘[http://127.0.0.1:8000/static/css/styles.css](http://127.0.0.1:8000/static/css/styles.css)’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled."  
This is the directory structure "

 ![Screenshot (52)](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/1/e/1e49a6f8fc1a6556e4c5151614d6165d47e83f99.png)  
"  
I will be very grateful if you can help me…

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 29, 2024, 1:28am UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/9 "2024-05-29T01:28:12Z")

</div>

Welcome @aimaarif !

This topic has been marked as solved. Your post is likely to get more attention if you opened a new topic for it.

When you do so, please show the view and the template being rendered here. Also post your settings.py file.

Post the text of the code into the body of your post, do not post images of code.

Side note: When posting code (or templates, error messages, tracebacks, etc), enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted. (I’ve taken the liberty of editing your original post. Please remember to do this in the future.)

---

<div class="post-metadata">

**Author:** ![THECH13F](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/thech13f/32/21627_2.png) [@THECH13F](https://forum.djangoproject.com/u/THECH13F)\
**Post date:** [May 30, 2024, 6:03am UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/10 "2024-05-30T06:03:07Z")

</div>

i am getting the same error but in production my local host is working fine

settings.py

```auto
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

```

base.html

```auto
<link href="{% static "css/custom.css" %}" type="text/css" rel="stylesheet">

```

other css files are working but getting error only in this

and the error is  
[https://legalsync.co.in/static/css/custom.css](https://legalsync.co.in/static/css/custom.css)’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled.

---

<div class="post-metadata">

**Author:** ![Manika2023](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/manika2023/32/22974_2.png) [@Manika2023](https://forum.djangoproject.com/u/Manika2023)\
**Post date:** [August 1, 2024, 8:24am UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/11 "2024-08-01T08:24:22Z")

</div>

I am facing same problem,have you solved it?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 1, 2024, 12:21pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/12 "2024-08-01T12:21:47Z")

</div>

Welcome @Manika2023 !

Please see my reply at [MIME type (text/html) is not supported as css - #9 by KenWhitesell](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/9)

There are many different possibilities regarding the cause of this error. There’s no one-size-fits-all solution. If you’re encountering this specific error, please open a new topic for the discussion, and include the details about your situation.  
(development or production? static file settings in your static.py? The template rendering the css causing the error? A description of your directory structure and the location of these static files within that structure?)

---

<div class="post-metadata">

**Author:** ![Manika2023](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/manika2023/32/22974_2.png) [@Manika2023](https://forum.djangoproject.com/u/Manika2023)\
**Post date:** [August 1, 2024, 12:37pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/13 "2024-08-01T12:37:04Z")

</div>

Ok sir, thank for replying  
Actually, I have solved that problem by running python manage.py runserver -insecure . Actually my settings .py was configured correctly to static file. But not working, now it’s all fine after running this command

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 1, 2024, 12:44pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/14 "2024-08-01T12:44:21Z")

</div>

Just to be clear, if you’re doing this in your development environment, that’s ok. But if this is how you’re deploying your project to a live environment, it’s _seriously_ **wrong**. What you’ve done is work around the real issue by potentially creating other problems for yourself.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 8, 2024, 5:22pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/16 "2024-09-08T17:22:26Z")

</div>

Welcome @LirimIslamii !

If you have a specific issue with which you would like assistance, please create a new topic here for your issue, with as many details about it as you can provide.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 8, 2024, 5:35pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/18 "2024-09-08T17:35:08Z")

</div>

> [@LirimIslamii](#):
>
> I need so much your help sir, so much, can i contact you on whatsapp or something else?

I do not provide private assistance. If you have an issue needing to be resolved, I can try to help you here.

> [@LirimIslamii](#):
>
> in localhost works prefectly, in IIS not!

Note: I do not use IIS. I’m unable to provide any specific IIS-related assistance. Maybe someone else would be able to help you here.

As a new user, you can create a new topic.

Don’t post images of code, directories, etc.

Copy/paste the text data into the body of your post. If it is preformatted text like code, error messages, tracebacks, html, or templates, post the text between lines of three backtick - ` characters. This means you’ll have a line of ```, then the code (or html, etc), then another line of ```.

---

<div class="post-metadata">

**Author:** ![mehtechnifab](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mehtechnifab/32/23853_2.png) [@mehtechnifab](https://forum.djangoproject.com/u/mehtechnifab)\
**Post date:** [September 11, 2024, 3:48pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/20 "2024-09-11T15:48:27Z")

</div>

I ran into this issue in IIS - [this answer](https://stackoverflow.com/a/37760566/2682623) was very helpful to me - essentially, FastCGI set it up as a folder, but it needed to be an application.

---

<div class="post-metadata">

**Author:** ![HamdiAkoub](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hamdiakoub/32/30022_2.png) [@HamdiAkoub](https://forum.djangoproject.com/u/HamdiAkoub)\
**Post date:** [September 24, 2025, 12:43pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/21 "2025-09-24T12:43:37Z")

</div>

–Python fix  
After countless hours of late night searching, I was forced to find a fix of my own, and I’m here to share it.  
Being new to web development, I did not understand everything in my settings.py, especially the static caching and configs for my project.

Error main cause:  
I previously had a static folder on an upper level of the static folder I actually intended to us, a silly mistake that I didn’t think would affect anything, so later on I simply deleted that upper level static folder, rendering it as a useless additional folder that I don’t need. That’s when some css files started return a Not Found HTML response.  
Structure:  
`webapp`  
`clientapp`  
` static / This is the one I wanted (or thought) that my program was using.`  
`webproj`  
`static / This is what caused the error after deleting it.`

So, running:  
`python manage.py findstatic clientapp/static/cssfolder/file.css --verbosity 2`  
gave me:

`?: (staticfiles.W004) The directory 'project\webproj\static' in the STATICFILES_DIRS setting does not exist.`  
`Found 'select2/select2.min.js' here:`  
` project\webproj\clientapp\static\select2\select2.min.js`  
`Looking in the following locations:`  
` project\webproj\static`  
` project\venv\Lib\site-packages\django\contrib\admin\static`  
` project\webproj\clientapp\static`  
` project\venv\Lib\site-packages\django_select2\static`

So I commented out `STATICFILES_DIRS = [BASE_DIR / 'static']`  
And made sure `DJANGO_DEBUG=True`  
And deleted staticfiles folder cause I ran `collectstatic` before. / Also a silly mistake for local dev

Please note that I’m still new to the field having switched careers recently and have about a year of work experience so far, I successfully hosted my first Python web app a few days ago and still got so much to learn. Having that said, this fixed the error that gave me headaches for the past three days, and I hope it helps you get to it faster.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 24, 2025, 12:58pm UTC](https://forum.djangoproject.com/t/mime-type-text-html-is-not-supported-as-css/18795/22 "2025-09-24T12:58:05Z")

</div>

Welcome @HamdiAkoub !

We try to avoid suggesting that people do the wrong thing here.

> [@HamdiAkoub](#):
>
> And made sure `DJANGO_DEBUG=True`

This is what you **do not** want to do when you’re deploying a Django project.

Quoting directly from the docs at [Settings | Django documentation | Django](https://docs.djangoproject.com/en/5.2/ref/settings/#debug)

> **Never deploy a site into production with [`DEBUG`](https://docs.djangoproject.com/en/5.2/ref/settings/#std-setting-DEBUG) turned on.**

Yes, getting static (and media) files served correctly in your production environment can be frustrating the first time. But you really want to take the time to understand the `STATIC`-related settings and understand how they work with your web server to “do the right thing”.
