503 Service Unavailable
Fault: Server
TL;DR
Server temporarily unavailable.
The server is currently unable to handle the request due to temporary overloading or maintenance.
What This Error Means
The server is currently unable to handle the request due to temporary overloading or maintenance.
Server temporarily unavailable.
Common Causes
- Server maintenance
- Server overloaded
- Too many connections
- Resource exhaustion
- Application restart
How to Fix It (For Visitors)
- Wait a few minutes and try again
- Check Retry-After header
- Visit status page
How to Fix It (For Developers/Admins)
- Check server resources (CPU, RAM, disk)
- Scale infrastructure
- Implement load balancing
- Set Retry-After header
- Check database connections
- Review application pool settings
Code Examples
Here's how to return a 503 status code in various programming languages:
Python (Flask)
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/endpoint')
def endpoint():
return jsonify({"message": "Service Unavailable"}), 503
Node.js (Express)
const express = require('express');
const app = express();
app.get('/endpoint', (req, res) => {
res.status(503).json({ message: 'Service Unavailable' });
});
PHP
<?php
http_response_code(503);
header('Content-Type: application/json');
echo json_encode(['message' => 'Service Unavailable']);
?>
Go
package main
import (
"encoding/json"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(503)
json.NewEncoder(w).Encode(map[string]string{
"message": "Service Unavailable",
})
}
Java (Spring Boot)
@GetMapping("/endpoint")
public ResponseEntity<Map<String, String>> endpoint() {
Map<String, String> response = new HashMap<>();
response.put("message", "Service Unavailable");
return ResponseEntity.status(503).body(response);
}
Ruby (Sinatra)
get '/endpoint' do
status 503
json message: 'Service Unavailable'
end
Browser Compatibility
| Browser | Support | Notes |
|---|---|---|
| Chrome | ✓ Full Support | All versions |
| Firefox | ✓ Full Support | All versions |
| Safari | ✓ Full Support | All versions |
| Edge | ✓ Full Support | All versions |
Official Specification
This status code is defined in RFC 7231 Section 6.6.4.