# 414 URI Too Long

> The requested URI exceeds the server's maximum length limit. Learn about URI length limits and how to handle oversized requests.

Source: https://howhttpworks.com/status-codes/414
Last reviewed: 2026-10-04

> **TL;DR:** Your URL exceeds the server's length limit (usually from too many query parameters). Use POST method for large data instead.

## What is 414 URI Too Long?

A **414 URI Too Long** status code means the URI (URL) requested by the client is longer than the server is willing to process. Think of it like trying to write an address on an envelope that's too long to fit—the postal service can't process it because it exceeds their format limits.

This commonly happens when too much data is passed in query parameters, especially when GET requests are used inappropriately for large data submissions.

## When Does This Happen?

You'll see a 414 URI Too Long response in these common situations:

**1. Excessive Query Parameters**

```text
Too many filters or search parameters in URL
/search?param1=value1&param2=value2&... [5000+ characters] → 414
```

**2. Large Data in GET Request**

```text
Attempting to send large data via GET instead of POST
/api/submit?data=[huge-json-encoded-string] → 414
```

**3. Redirect Loop Accumulation**

```text
Redirect chain appending parameters each time
/page?a=1 → /page?a=1&b=2 → /page?a=1&b=2&c=3 → ... → 414
```

**4. Array/List in Query String**

```text
Passing large arrays via URL
/filter?ids[]=1&ids[]=2&ids[]=3... [1000 IDs] → 414
```

**5. Base64-Encoded Data in URL**

```text
Embedding large files in query parameters
/preview?image=data:image/png;base64,[100KB of data] → 414
```

## Example Responses

**Basic URI Too Long:**

```http
HTTP/1.1 414 URI Too Long
Content-Type: application/json
Content-Length: 245

{
  "error": "URI Too Long",
  "message": "The requested URI exceeds the maximum allowed length",
  "uri_length": 10240,
  "max_allowed_length": 8192,
  "suggestion": "Use POST method to send large amounts of data"
}
```

**With Alternative Endpoint:**

```http
HTTP/1.1 414 URI Too Long
Content-Type: application/json
Link: <https://api.example.com/search>; rel="alternate"; method="POST"

{
  "error": "URI Too Long",
  "message": "Query string exceeds maximum length of 4096 characters",
  "uri_length": 5823,
  "max_length": 4096,
  "alternatives": {
    "post_endpoint": {
      "url": "/api/search",
      "method": "POST",
      "description": "Send search parameters in request body"
    }
  },
  "documentation": "https://docs.example.com/api/search-limits"
}
```

**Server-Specific Limits:**

```http
HTTP/1.1 414 URI Too Long
Content-Type: text/html
Server: nginx/1.24.0

<!DOCTYPE html>
<html>
<head><title>414 URI Too Long</title></head>
<body>
<h1>Request URI Too Long</h1>
<p>The requested URL's length exceeds the capacity limit for this server.</p>
<p>Maximum allowed URI length: 8192 characters</p>
<p>Your request length: 12456 characters</p>
<p>Please reduce the URL length or use POST method instead.</p>
</body>
</html>
```

## Real-World Example

Imagine you're building a report filtering system with too many parameters:

**Client Request with Excessive Parameters:**

```http
GET /api/reports?year=2026&month=1&month=2&month=3&month=4&month=5&month=6&month=7&month=8&month=9&month=10&month=11&month=12&category=sales&category=marketing&category=operations&category=hr&category=finance&category=it&region=north&region=south&region=east&region=west&product_id=1&product_id=2&product_id=3...[continues for 500 products]...&format=pdf&include_charts=true&include_tables=true&include_summary=true&timezone=America/New_York HTTP/1.1
Host: api.example.com
Accept: application/json
```

**Server Response:**

```http
HTTP/1.1 414 URI Too Long
Content-Type: application/json
Link: <https://api.example.com/reports/query>; rel="alternate"; method="POST"
X-Max-URI-Length: 8192
X-Actual-URI-Length: 15234

{
  "status": 414,
  "error": "URI Too Long",
  "message": "Request URI exceeds server maximum length",
  "details": {
    "max_uri_length": 8192,
    "actual_uri_length": 15234,
    "excess_length": 7042,
    "query_param_count": 523
  },
  "solution": {
    "description": "Use POST method for complex queries",
    "endpoint": "/api/reports/query",
    "method": "POST",
    "example": {
      "url": "https://api.example.com/api/reports/query",
      "method": "POST",
      "headers": {
        "Content-Type": "application/json"
      },
      "body": {
        "year": 2026,
        "months": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
        "categories": ["sales", "marketing", "operations"],
        "product_ids": [1, 2, 3, "..."]
      }
    }
  },
  "documentation": "https://docs.example.com/api/query-limits"
}
```

## 414 vs Other Request Error Codes

| Code    | Meaning           | Issue                    | Solution                  |
| ------- | ----------------- | ------------------------ | ------------------------- |
| **414** | URI too long      | URL exceeds length limit | Use POST or shorten URL   |
| **413** | Payload too large | Request body too big     | Reduce body size or chunk |
| **400** | Bad request       | Malformed request        | Fix request syntax        |
| **431** | Headers too large | Request headers too big  | Reduce header size        |

## Important Characteristics

**Common URI Length Limits:**

```text
Browser limits:
- Chrome: ~2MB (practical limit ~32KB)
- Firefox: ~65,536 characters
- Safari: ~80,000 characters
- IE/Edge: 2,083 characters (legacy)

Server limits:
- Apache: 8,190 bytes (default)
- Nginx: 4K-8K bytes (configurable)
- IIS: 16,384 characters (configurable)
- Node.js: 80KB (http-parser default)
```

**Query String vs Request Body:**

```http
GET with long query string:
/api/search?q=long&filters=[huge array] → Risk of 414

POST with request body:
POST /api/search
Body: {"q": "long", "filters": [...]} → Better approach
```

**URL Encoding Overhead:**

```http
Original: "hello world"
Encoded: "hello%20world"  ← 20% increase in length
```

## Common Mistakes

**❌ Using GET for large data submissions**

```http
GET /api/submit?data=[10KB of base64 encoded data] → 414
```

**❌ Putting arrays in query string**

```http
GET /filter?ids=1,2,3,4,5,6,7,8...[500 IDs] → 414
```

**❌ Encoding entire objects in URL**

```http
GET /preview?config={"theme":"dark","options":[...]...} → 414
```

**✅ Use POST for large data**

```http
POST /api/submit
Content-Type: application/json

{
  "data": "[large payload]",
  "ids": [1, 2, 3, 4, 5, ...]
}
```

## Getting 414 URI Too Long right

**Use POST for Large Data:**

```javascript
// Bad: GET with huge query string
fetch('/api/search?filters=' + encodeURIComponent(JSON.stringify(largeFilters)))

// Good: POST with body
fetch('/api/search', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ filters: largeFilters })
})
```

**Implement Pagination and Filtering:**

```javascript
// Bad: Request all IDs at once
/api/records?ids=1,2,3,4,5...[1000 IDs]

// Good: Use pagination or POST
POST /api/records/batch
{"ids": [1, 2, 3, ...], "page": 1, "limit": 100}
```

**Provide Clear Error Messages:**

```http
HTTP/1.1 414 URI Too Long
Content-Type: application/json

{
  "error": "URI Too Long",
  "message": "URL exceeds 8192 character limit",
  "current_length": 12456,
  "max_length": 8192,
  "recommendations": [
    "Use POST method instead of GET",
    "Reduce number of query parameters",
    "Use request body for large data",
    "Implement pagination for large result sets"
  ],
  "alternative_endpoints": [
    {
      "method": "POST",
      "url": "/api/search",
      "description": "Submit search parameters in request body"
    }
  ]
}
```

**Configure Server Limits Appropriately:**

```nginx
# Nginx configuration
large_client_header_buffers 4 16k;
http {
    # Increase URI size limit
    client_header_buffer_size 16k;
}
```

```apache
# Apache configuration
LimitRequestLine 16384
```

## Implementation Examples

**Express.js Error Handling:**

```javascript
const express = require('express')
const app = express()

// Set maximum URL length
app.use((req, res, next) => {
  const MAX_URL_LENGTH = 8192
  const fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl

  if (fullUrl.length > MAX_URL_LENGTH) {
    return res.status(414).json({
      error: 'URI Too Long',
      message: 'Request URL exceeds maximum allowed length',
      current_length: fullUrl.length,
      max_length: MAX_URL_LENGTH,
      suggestion: 'Use POST method for large data submissions'
    })
  }

  next()
})

// Alternative POST endpoint for long queries
app.post('/api/search', (req, res) => {
  const { filters, sort, pagination } = req.body
  // Handle search with body parameters
  res.json({ results: performSearch(req.body) })
})
```

**Django:**

```python
from django.http import JsonResponse
from django.conf import settings

class URILengthMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response
        self.max_uri_length = getattr(settings, 'MAX_URI_LENGTH', 8192)

    def __call__(self, request):
        full_path = request.build_absolute_uri()

        if len(full_path) > self.max_uri_length:
            return JsonResponse({
                'error': 'URI Too Long',
                'message': f'URI length {len(full_path)} exceeds maximum {self.max_uri_length}',
                'max_length': self.max_uri_length,
                'current_length': len(full_path),
                'alternative': {
                    'method': 'POST',
                    'endpoint': request.path
                }
            }, status=414)

        return self.get_response(request)
```

**ASP.NET Core:**

```csharp
public class URILengthMiddleware
{
    private readonly RequestDelegate _next;
    private const int MaxUriLength = 8192;

    public URILengthMiddleware(RequestDelegate next)
    {
        _next = next;
    }

    public async Task InvokeAsync(HttpContext context)
    {
        var uri = $"{context.Request.Scheme}://{context.Request.Host}{context.Request.Path}{context.Request.QueryString}";

        if (uri.Length > MaxUriLength)
        {
            context.Response.StatusCode = 414;
            context.Response.ContentType = "application/json";

            await context.Response.WriteAsJsonAsync(new
            {
                error = "URI Too Long",
                message = "Request URI exceeds maximum allowed length",
                current_length = uri.Length,
                max_length = MaxUriLength,
                suggestion = "Use POST method for large data"
            });

            return;
        }

        await _next(context);
    }
}
```

## Client-Side Prevention

**Check URL Length Before Sending:**

```javascript
function makeAPIRequest(endpoint, params) {
  const queryString = new URLSearchParams(params).toString()
  const fullUrl = `${endpoint}?${queryString}`

  const MAX_URL_LENGTH = 8000 // Conservative limit

  if (fullUrl.length > MAX_URL_LENGTH) {
    // Switch to POST automatically
    return fetch(endpoint, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(params)
    })
  }

  // Safe to use GET
  return fetch(fullUrl)
}
```

**Paginate Large Requests:**

```javascript
// Bad: All IDs at once
const ids = Array.from({ length: 1000 }, (_, i) => i + 1)
fetch(`/api/items?ids=${ids.join(',')}`) // URI too long!

// Good: Batch requests
async function fetchItemsInBatches(ids, batchSize = 100) {
  const results = []

  for (let i = 0; i < ids.length; i += batchSize) {
    const batch = ids.slice(i, i + batchSize)
    const response = await fetch('/api/items', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ ids: batch })
    })
    results.push(...(await response.json()))
  }

  return results
}
```

## Try It Yourself

Visit our [request builder](https://howhttpworks.com/tools/playground) and trigger a 414 response:

1. Set method to **GET**
2. Set path to **/api/search**
3. Add query with 1000+ parameters
4. Click **Send request**
5. See 414 with suggested POST alternative

## Try it with curl

Build a URL longer than the server's request-line limit. nginx's default is 8 KB per header buffer (`large_client_header_buffers 4 8k`), so 10,000 characters is enough there.

```bash
curl -i "https://api.example.com/search?q=$(head -c 10000 /dev/zero | tr '\0' 'a')"
```

Example output (illustrative, not captured from a real server):

```http
HTTP/1.1 414 Request-URI Too Large
Server: nginx
```

The reason phrase differs by server (RFC 9110 calls the status `URI Too Long`). Limits vary, so change the `head -c` count to find a given server's threshold.

## Related Status Codes

- [413 Payload Too Large](https://howhttpworks.com/status-codes/413) - Request body exceeds size limit
- [431 Request Header Fields Too Large](https://howhttpworks.com/status-codes/431) - Request headers too large
- [400 Bad Request](https://howhttpworks.com/status-codes/400) - Malformed request
- [200 OK](https://howhttpworks.com/status-codes/200) - Successful request with appropriate size
