Laravel application csrf token giving 419 when using docker

I’m working on a Laravel application that I’m running locally using Docker. The application loads, but I’m facing an issue with the CAPTCHA and login.

When I try to access a page with a CAPTCHA, it fails to generate.

In the browser’s Network tab, I see a 419 Page Expired error.

If I manually bypass the CSRF token (not ideal), the CAPTCHA appears — but I still can’t log in to the application.

I suspect the issue is related to CSRF tokens and session handling in Docker.

Docker Compose for local setup

Nginx as reverse proxy inside Docker

What’s a session in Docker? Docker is for isolation, it only containerizes the application you are running. I don’t think it will add any session or caching.

is it possible to give me any example of session that help me to add on .env file
SESSION_DRIVER=file

SESSION_LIFETIME=120

SESSION_ENCRYPT=false

SESSION_PATH=/

SESSION_DOMAIN=null

SESSION_DOMAIN=.localhost

SESSION_CONNECTION=custom

SESSION_SECURE_COOKIE=false

SESSION_SAME_SITE=lax
those thing i add

Maybe check the doc?

nothing in doc. if you have any another option ?

This topic was marked as solved, but you have sent an unanswered question so I wonder, did you really solve your issue?

yes
I m not able to solve this problem still

how to solve CSRF token issue in docker

The topic is still marked as solved making the following post the solution:

Please remove the solution flag by clicking on the “Solution” label and click on the heart icon as well if you accidentally clicked on the other option originally instead of liking @bluepuma77 's post.

Regarding your question, you are trying to solve something not really related to Docker. The way you can solve it is the same as without Docker. You need to get log messages and figure out what causes it. You cans earch for “HTTP 419” to find some tips like here:

https://error404.atomseo.com/blog/status-code-419

In your case, the container has the same role as a physical webserver or a virtual machine would have and you will need the same debugging methods. The only difference is how you get the logs. Probably not by reading files inside the container, but it depends on the app. If it logs to files, then you need to read the log files. If it logs to the standard output and error streams, you can use the docker logs. command or docker compose logs

The Laravel documentation can give you more ideas, but you can search directly for “Laravel login http 419” to find something like this:

https://stackoverflow.com/questions/71543908/laravel-returns-419-page-expired-after-signin-register-on-chrome-edge-brows

It doesn’t mean this is your problem, but if you need any help with configuring Laravel properly, Laravel users can give you a better guide. If you are using a Laravel Docker image, you can check the description of the image too.

The problem was not resolve