HTTPError.net

The fastest way to diagnose, understand, and fix any HTTP status code

402 Payment Required

Fault: Client
TL;DR

Reserved by the spec but now widely used by APIs (Stripe, GitHub, cloud providers) to signal that a paid plan, credit, or valid payment method is required.

The request cannot be processed until the client makes a payment.

What HTTP 402 Payment Required Means

The request cannot be processed until the client makes a payment.

Reserved by the spec but now widely used by APIs (Stripe, GitHub, cloud providers) to signal that a paid plan, credit, or valid payment method is required.

Common Causes

How to Fix It (For Visitors)

How to Fix It (For Developers/Admins)

Returning a 402 Payment Required (Code Examples)

If you build APIs or web apps, here is how to send an HTTP 402 response and how to test for it:

Node.js (Express)

app.get('/resource', (req, res) => {
  res.status(402).json({ error: 'Payment Required' });
});

Python (Flask)

@app.route('/resource')
def resource():
    return jsonify(error='Payment Required'), 402

PHP

<?php
http_response_code(402);
header('Content-Type: application/json');
echo json_encode(['error' => 'Payment Required']);

Check the status with curl

curl -I https://example.com/resource
# Look for: HTTP/1.1 402 Payment Required

Frequently Asked Questions

What does HTTP 402 Payment Required mean?

Reserved by the spec but now widely used by APIs (Stripe, GitHub, cloud providers) to signal that a paid plan, credit, or valid payment method is required. In short: The request cannot be processed until the client makes a payment.

Is 402 Payment Required a client or server error?

402 is a 4xx client-error code, so the request itself needs to change. The server is running normally and is rejecting the request as it was sent by the browser, app, or API client.

How do I fix a 402 Payment Required error?

Return 402 with a clear billing message and link. Document required plans in your API reference. Include the failed charge ID for support.

Official Specification

The 402 Payment Required status code is defined in RFC 9110 Section 15.5.3.

View the IANA HTTP Status Code Registry →