1 min read

Matrix Clients Cannot Download Content or Login

TL;DR;

If NGINX doesn't own /var/lib/nginx or /var/cache/nginx to store temporary files, it will terminate file transmissions before they finish, causing errors.

The solution is to make sure the NGINX worker user has ownership/access (in my case www-data), i.e. chown -R www-data:www-data /var/cache/nginx


Since I set up my matrix server, it has been running smoothly, and there haven't been any problems. However, recently, when I configured a server and changed some things on the server, there appeared to be a weird problem of being unable to send images and connection errors when trying to sign in to new clients. Weird!

So I checked the homeserver logs, and the only errors were those of other federated servers, which returned 404/500 errors.

So, probably not the synapse server itself, but perhaps something about the clients, I thought?

So I tested it on my other devices on different platforms. Yet, they all had the same problem (mostly, except for Element on Android, weirdly enough), eliminating the possibility of problems in the clients.

Download Error in the Developer Console

The errors on the clients were also not the most helpful, simply stating "Download Error." The console, however, does present a common problem between all the clients: net::ERR_CONTENT_LENGTH_MISMATCH

So I came to the conclusion that it has to do with NGINX, which is failing, did some simple research and found that it was indeed a problem.

Apparently when I was installing some new services and on the server, reinstalling NGINX in the process, the ownership of the folders were changed, all that had to be done was to change them back.

chown -R www-data:www-data /var/cache/nginx
chown -R www-data:www-data /var/lib/nginx

After resolving the permission errors for nginx temporary file folders, everything is back to normal!