Free auditStart free
GuideError · HTTP status codes

403 Forbidden in Laravel

Trace a Laravel 403 to its source: a failed Gate or policy, the can middleware, abort(403) or a guest user. Includes policy fixes and custom error page steps.

3 min
read
3
sources
Nov 1, 2026
updated
Scaplet Editorial Team
author
The short answer

In Laravel, a 403 usually means an authorization check said no. Gate::authorize, a policy method, the can middleware or an explicit abort(403) throws an exception that the framework turns into a 403 response. Find the check on that route, then fix the policy logic, the user, or the model it receives.

  1. Which check produced the 403
  2. Reproduce and check it in 2 minutes
  3. Fix the policy, not the symptom
  4. Show a custom 403 page
  5. What it means for SEO and crawlers
30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Authorization paths that end in 403, per the Laravel authorization docs

Which check produced the 403

Laravel separates authentication (who are you) from authorization (may you do this). The 403 belongs to the second. The general meaning is on 403 Forbidden; a missing login is a different problem, covered in 401 in Laravel.
Where it fires

Controller, gate

Code
Gate::authorize('update-post', $post)
Result
Throws AuthorizationException, converted to a 403
Where it fires

Controller, policy via user model

Code
if ($request->user()->cannot('update', $post)) { abort(403); }
Result
Explicit 403
Where it fires

Route middleware

Code
->middleware('can:update,post') or ->can('update', 'post')
Result
The middleware returns a 403 when the user is not authorized
Where it fires

Inline

Code
Gate::allowIf(...) or Gate::denyIf(...)
Result
Throws AuthorizationException if denied or no user is authenticated
Where it fires

Any code

Code
abort(403)
Result
Throws an HTTP exception with that status

Search your routes and controllers for those calls, starting with the route that fails. The can middleware often hides in a route group, so check group definitions as well as the single route.

02Check it

Reproduce and check it in 2 minutes

Then list the middleware on the failing route and ask the framework what the policy says. These commands run inside your Laravel project:

Your own project: find the route and its middleware
php artisan route:list --path=posts
# Expect a table with a Middleware column. Look for can:update,post or an auth group.
php artisan tinker
# >>> Gate::forUser(App\Models\User::find(1))->allows('update', App\Models\Post::find(1))
# Expect true or false for that user and record.

If tinker says false, the policy logic or the data is the cause, not routing. If it says true and the route still returns 403, a different check is firing, such as an explicit abort(403) or middleware.

Public endpoint: confirm your client reads a 403
curl -i https://httpbin.org/status/403
# Expect: HTTP/2 403. Use the same -i flag on your own route to see the status line
# and whether the body is HTML or JSON.
03Fix it on your stack

Fix the policy, not the symptom

Most 403s come from a policy comparing the wrong things. The docs' own policy compares the user's id with the post's user_id:
app/Policies/PostPolicy.php
public function update(User $user, Post $post): bool
{
    return $user->id === $post->user_id;
}
Allow a null user into the policy
public function update(?User $user, Post $post): bool
{
    return $user?->id === $post->user_id;
}
Return 404 instead of 403
use Illuminate\Auth\Access\Response;

public function update(User $user, Post $post): Response
{
    return $user->id === $post->user_id
        ? Response::allow()
        : Response::denyAsNotFound();
}

Strict comparison with === fails when one side is a string and the other an integer, which can happen with values from request input or an unusual driver. Check the types in tinker before assuming a permissions problem. Also confirm the policy is found: by default Laravel discovers a policy when the model and policy follow its naming conventions, so a Post model needs a PostPolicy in a Policies directory at or above the models. With no registered policy, can falls back to a closure Gate of the same name.

Guests are a special case. By default every gate and policy returns false when the request was not made by an authenticated user. A signed-out visitor hitting an authorize call therefore gets a 403 rather than a login prompt. To let guests through to the check, make the user argument optional:

If you would rather not reveal that a resource exists, the docs offer Response::denyAsNotFound(), or Response::denyWithStatus(404) for another code, in place of the default 403:

04Check it

Show a custom 403 page

Create resources/views/errors/403.blade.php. The error handling docs say views in that directory are named for the status code they serve, and the HttpException raised by abort is passed in as $exception.

Publish the default templates with php artisan vendor:publish --tag=laravel-errors if you want a starting point. A 4xx.blade.php file acts as a fallback for codes without their own page. For JSON clients, Laravel picks HTML or JSON by the request's Accept header, and you can change that rule with shouldRenderJsonWhen.

resources/views/errors/403.blade.php
<h2>{{ $exception->getMessage() }}</h2>
05Explained

What it means for SEO and crawlers

Google treats 4xx codes other than 429 alike: content from those URLs is ignored, and 401 and 403 have no effect on crawl rate. Policies usually guard account pages that should not be indexed anyway. Trouble starts when a policy or can middleware wraps a public route, so Googlebot, which is not signed in, gets a 403. Fetch the URL with curl as a guest to see what a crawler sees. For finding affected URLs, see 4xx errors.

Sources · 3

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • laravel.com
  • google.com
  1. 01Laravel 12.x authorizationlaravel.com · checked 2026-11-01
  2. 02Laravel 12.x error handlinglaravel.com · checked 2026-11-01
  3. 03How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-11-01
Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01What status does Gate::authorize return?

It throws an AuthorizationException when the action is not allowed, and Laravel's exception handler converts that into a 403 response.

02Why do signed-out users get 403 instead of a login redirect?

Gates and policies return false for guests by default, so an authorize call fails with 403. Protect the route with the auth middleware first if you want unauthenticated users sent to login.

03How do I return 404 instead of 403 for a denied resource?

Return Response::denyAsNotFound() from the policy or gate, or Response::denyWithStatus() with the status you want.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane