Return 503 on database connection error

Fixes issues #23332.
Merge branch '4.2/database-error-503' into 4.2-trunk