Chapter

Common errors and fixes

A problem-and-solution reference for the nginx errors you hit most often: 502, 413, 403, 504, redirect loops, port conflicts, and more.

Nginx Basics 8 Lessons from courses

About this chapter

This chapter is a reference you can jump into when something breaks. Each lesson takes one specific nginx error, shows the exact text you see in the browser and the log, explains why it happens, and gives you the fix.

Lessons from courses

  1. 1 Nginx 502 Bad Gateway - Causes and Fix Fix nginx 502 Bad Gateway: PHP-FPM down, wrong fastcgi_pass socket, wrong proxy_pass port, or socket permissions. Diagnose with the error log.
  2. 2 Nginx 413 Request Entity Too Large - Fix Fix nginx 413 Request Entity Too Large: raise client_max_body_size above the default 1M, reload, and bump PHP upload_max_filesize too.
  3. 3 Nginx 403 Forbidden - Causes and Fix Fix nginx 403 Forbidden: file permissions, missing index file with autoindex off, deny rules, or a wrong root. Diagnose with the error log.
  4. 4 Nginx 504 Gateway Timeout - Causes and Fix Fix nginx 504 Gateway Timeout: raise fastcgi_read_timeout or proxy_read_timeout, but remember the real fix is usually a slow backend.
  5. 5 Nginx ERR_TOO_MANY_REDIRECTS - Redirect Loop Fix Fix nginx ERR_TOO_MANY_REDIRECTS: an HTTP to HTTPS loop behind Cloudflare or a proxy. Check X-Forwarded-Proto or switch Cloudflare to Full SSL.
  6. 6 Nginx bind() to 0.0.0.0:80 failed (98: Address already in use) Fix nginx bind() to 0.0.0.0:80 failed (98: Address already in use): find the service holding port 80 or the duplicate default_server, then reload.
  7. 7 Nginx Not Serving Static Files - CSS Not Loading Fix Fix nginx not serving static files: wrong root or alias, missing try_files, missing mime.types (CSS as text/plain), permissions, or a greedy front controller.
  8. 8 Nginx Shows Welcome Page Instead of My Site - Fix Fix nginx showing the default Welcome to nginx page: disable the default site, symlink your config into sites-enabled, match server_name, and reload.
Nginx Basics Go to course