Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSRF token is missing error in docker pgadmin

I am trying to create a docker-compose stack with pg and pgadmin as follows,

version: '3.1'
services:
  pg-admin:
    image: dpage/pgadmin4
    volumes:
        - /Users/pkaramol/Desktop/backup.tar:/pgadmin4/dvdrental.tar
    ports:
      - "8181:80"
    environment:
      PGADMIN_DEFAULT_EMAIL: [email protected]
      PGADMIN_DEFAULT_PASSWORD: 1234
    depends_on:
    - pg
  pg:
    image: postgres:12
    volumes:
      - ./pg-data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    restart: always

but pgadmin logs error out as follows:

pg-admin_1  | Traceback (most recent call last):
pg-admin_1  |   File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1811, in full_dispatch_request
pg-admin_1  |     rv = self.preprocess_request()
pg-admin_1  |   File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2087, in preprocess_request
pg-admin_1  |     rv = func()
pg-admin_1  |   File "/usr/local/lib/python3.8/site-packages/flask_wtf/csrf.py", line 224, in csrf_protect
pg-admin_1  |     self.protect()
pg-admin_1  |   File "/usr/local/lib/python3.8/site-packages/flask_wtf/csrf.py", line 259, in protect
pg-admin_1  |     self._error_response(e.args[0])
pg-admin_1  |   File "/usr/local/lib/python3.8/site-packages/flask_wtf/csrf.py", line 302, in _error_response
pg-admin_1  |     raise CSRFError(reason)
pg-admin_1  | flask_wtf.csrf.CSRFError: 400 Bad Request: The CSRF session token is missing.

Any suggestions?

like image 887
pkaramol Avatar asked Oct 16 '20 18:10

pkaramol


People also ask

How do I fix a missing CSRF token?

Invalid or missing CSRF token This error message means that your browser couldn't create a secure cookie, or couldn't access that cookie to authorize your login. This can be caused by ad- or script-blocking plugins, but also by the browser itself if it's not allowed to set cookies.

How do I connect PgAdmin to Docker container?

PgAdmin Docker Setup: Docker Images and Docker Compose. PgAdmin Docker Setup: Creating The Docker Compose File. PgAdmin Docker Setup: Verification of Docker Connection. PgAdmin Docker Setup: Set up the PostgreSQL Connection.


2 Answers

Make sure that you close tab that were connected to pgAdmin before start the container.

like image 99
rjhcnf Avatar answered Oct 19 '22 18:10

rjhcnf


Maybe you are running multiple instances of pgAdmin on the same host? At least for us this was the problem. Shutting down one of them resolved the issue.

like image 32
Stuck Avatar answered Oct 19 '22 20:10

Stuck