I was using Django as my website backend framework, and it was my first time to do the backend stuff myself. After some days ramp up and search, I found the Cookiecutter Django provides a very good project template which could be used in a production level.

Few days struggling, I finally get into the last deployment step. I followed the document to deploy the website on Heroku.

However, after I got an error, the website shows “Internal Service Error” and opbeat send me this error:

UncompressableFileError:https://s3.amazonaws.com:443/*bucket-name*/static/css/project.css' isn’t accessible via COMPRESS_URL (‘https://s3.amazonaws.com/*bucket-name*/static/') and can’t be compressed.

However, I was able to open the project.css directly in the browser, how come I don’t have access to the directory?

It took me hours to search and I still couldn’t figure it out. Then I decided to look into the source code and found this:

1
2
3
4
if not url.startswith(base_url):
raise UncompressableFileError("'%s' isn't accessible via"
"COMPRESS_URL ('%s') and can't be"
"compressed"%(url, base_url))

Comparing to the error I received, we could conclude that:

Found the difference?

YEP, the base_url missing the port number!
Because in the source code, the Python code used url.startswith() method, thus the url should be exactly match!

So in the production.py file modify the STATIC_URL as following:

1
2
STATIC_URL = 'https://s3.amazonaws.com:443/%s/static/' % AWS_STORAGE_BUCKET_NAME
COMPRESS_URL = STATIC_URL

Commit the change, the website is alive!