HTTP 405 Method Not Allowed means the HTTP method (GET, POST, PUT, DELETE) used in the request is not supported for the target resource. The server MUST include an Allow header listing the methods that are supported. This differs from 501 Not Implemented (the server doesn't support the method at all) — 405 means the resource exists but doesn't accept that specific method.
Response includes the status code, standard headers (including Content-Type), and a small diagnostic JSON body describing the request and returned status.
Simulator URL (copy in the app after load — not a normal link):
https://httpstatus.com/api/status/405
Example request:
curl -i "https://httpstatus.com/api/status/405"A request method is not supported for the requested resource.
On this code, Inspector focuses on semantics, headers, and correctness warnings that commonly affect clients and caches.
HTTP 405 Method Not Allowed has specific technical implications for API design, caching, and client behavior. Understanding the precise semantics helps distinguish it from similar status codes and implement correct error handling. The response should include a descriptive body following a consistent error schema (like RFC 7807 Problem Details) so clients can programmatically handle the error.
// Handle 405 Method Not Allowed in Express
app.use((err, req, res, next) => {
if (err.status === 405) {
return res.status(405).json({
type: 'https://api.example.com/errors/method-not-allowed',
title: 'Method Not Allowed',
status: 405,
detail: err.message
});
}
next(err);
});from fastapi import HTTPException
# Raise 405 Method Not Allowed
raise HTTPException(
status_code=405,
detail={
'type': 'method_not_allowed',
'message': 'Descriptive error for 405 Method Not Allowed'
}
)// Spring Boot 405 Method Not Allowed handling
@ExceptionHandler(CustomMethodNotAllowedException.class)
public ResponseEntity<ErrorResponse> handleMethodNotAllowed(
CustomMethodNotAllowedException ex) {
return ResponseEntity.status(405)
.body(new ErrorResponse("Method Not Allowed", ex.getMessage()));
}// Return 405 Method Not Allowed
func errorHandler(w http.ResponseWriter, message string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(405)
json.NewEncoder(w).Encode(map[string]any{
"status": 405,
"error": "Method Not Allowed",
"message": message,
})
}