HTTP status codes: server errors (5xx)
This course covers HTTP 5xx status codes, the responses a server sends when it fails to fulfill a valid request. It explains how 5xx differs from 4xx and where errors come from across proxy, app server, application and database layers. Lessons walk through 500, 502, 503 and 504 with causes and debugging steps in a Rails setup with Nginx and Puma. The course also covers timeout chains, maintenance pages, logging levels, error tracking services, health checks, rescue_from, custom error pages and the Rails.error API.
What you'll learn
- ✓How 5xx errors differ from 4xx errors and which infrastructure layer returns each code
- ✓Common causes of 500 errors in Rails and how to map exceptions to the correct status code
- ✓How to debug 502 and 504 errors using Nginx, Puma, Rails and database logs
- ✓Using 503 with the Retry-After header and serving maintenance pages
- ✓Configuring timeouts in descending order across Nginx, rack-timeout and PostgreSQL
- ✓Logging, error tracking, alerting and error handling with rescue_from and Rails.error
What are server error status codes?
Imagine you walk into a restaurant and place your order perfectly: correct item, correct table, valid payment. But then the kitchen catches fire. That's not your fault as a customer; the restaurant can't fulfill your request right now.
Read the full lesson free →Curriculum
7 lessonsWhat are server error status codes?
Explains what 5xx codes mean, how they differ from 4xx, and which layers can produce them.
500 Internal Server Error
Covers causes of 500 errors in Rails, how Rails handles them, and how to return more specific codes.
502 Bad Gateway
Describes how a proxy returns 502 after an invalid upstream response, plus debugging and prevention steps.
503 Service Unavailable
Covers 503 from maintenance or overload, the Retry-After header, load balancers and maintenance pages in Rails.
504 Gateway timeout
Explains proxy timeouts, the descending timeout chain, slow queries, background jobs and a 504 debugging checklist.
Error monitoring and logging
Covers logger levels, structured logging, error tracking services, alerting, server health metrics and health check endpoints.
Server errors in Rails
Shows rescue_from, static and dynamic error pages, Rails.error handle and record, error tests and best practices.