1

i used celery in my django project .django are running with uWSGI and can work with postgresql well but it's seem that celery can't connect to postgresql :

Traceback (most recent call last):
  File "/home/classgram/www/env/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
    self.connect()
  File "/home/classgram/www/env/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/home/classgram/www/env/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/home/classgram/www/env/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  password authentication failed for user "hamclassy"
FATAL:  password authentication failed for user "hamclassy"

i'm working on host and host OS is Ubuntu 18.04 . thank you

7
  • 1
    Check if hamclassy user exists in Postgres. Commented Aug 13, 2019 at 8:16
  • 1
    And if hamclassy exists you'll need to check if the host that celery is running from is allowed to log in as hamclassy. Could be that the django host has access and celery doesn't. Commented Aug 13, 2019 at 8:23
  • @SergeyPugach : the hamclassy role exist.when i run SELECT 1 FROM pg_roles WHERE rolname='hamclassy' return 1 . Commented Aug 13, 2019 at 8:25
  • @azundo . how i can check it? sorry but i'm new in Unix OS terminal and i don't know enough about users and permissions.when running htop command i can see that celery and uwsgi both are running with user classgram , so what i must do to check if classgram can access postgresql or not? Commented Aug 13, 2019 at 8:27
  • 1
    This problem has nothing to do with Celery - it is obviously a typical PostgreSQL Access control issue. Commented Aug 13, 2019 at 10:38

1 Answer 1

1

This problem has nothing to do with Celery - it is obviously a typical PostgreSQL Access control issue.

It seems like your PostgreSQL server allows hamclassy role (user) to connect from machine where Django runs, but does not allow access from your Celery workers. The right place to look for solution to your problem is the pg_hba.conf file on the PostgreSQL server.

On most Linux distributions locate pg_hba.conf should give you location of the file. Fedora has it here: /var/lib/pgsql/data/pg_hba.conf. Ubuntu on the other hand has it in /etc/postgresql. (Example: /etc/postgresql/9.6/main/pg_hba.conf)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.