Saleor: Unable to install saleor

Created on 24 May 2018  Â·  22Comments  Â·  Source: mirumee/saleor

Did create a database named saleor with "createdb saleor"
Did create a superuser named saleor with "createuser -s --pwprompt saleor"
Password for the super user is as default "saleor"

I am not sure why am i getting this error. I did find some similar issues and fallowed them through but did not solve my problem. I would really appreciate any help.

(ecommerce) [root@site saleor]# python manage.py migrate
System check identified some issues:

WARNINGS:
saleor.W001: Session caching cannot work with locmem backend
    HINT: User sessions need to be globally shared, use a cache server like Redis.
Traceback (most recent call last):
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
    self.connect()
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 168, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/root/environments/ecommerce/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  Ident authentication failed for user "saleor"


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 79, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
    self.build_graph()
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/migrations/loader.py", line 206, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 61, in applied_migrations
    if self.has_table():
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 44, in has_table
    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/backends/base/base.py", line 255, in cursor
    return self._cursor()
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/backends/base/base.py", line 232, in _cursor
    self.ensure_connection()
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
    self.connect()
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
    self.connect()
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/root/environments/ecommerce/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 168, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/root/environments/ecommerce/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL:  Ident authentication failed for user "saleor"

Most helpful comment

It should be :+1:

Let's try to force the password of the database user saleor to be saleor.
As root, run (copy/paste):

psql postgres postgres <<EOF
ALTER USER saleor WITH ENCRYPTED PASSWORD 'saleor';
\q
EOF

If the console prints:

ERROR:  role "saleor" does not exist

Recreate the user (run as root, or as postgres (sudo -sHu postgres)):

createuser -U postgres -s --pwprompt saleor

Because I suspect that it may have failed previously as it may have been run as root and not as postgres. But I think it depends on the Linux distributions sometimes.

All 22 comments

My guess is that database is incorrectly configured. It seems like you are using Ident based authentication. Are you sure that you have correct mapping? Consult with this
https://www.postgresql.org/docs/9.1/static/auth-username-maps.html
https://www.postgresql.org/docs/9.1/static/auth-methods.html#AUTH-IDENT

BTW, did you check if you can log in to database?
I also found some similar issues, please check, maybe one of them will be helpful for you
https://serverfault.com/questions/406606/postgres-error-message-fatal-ident-authentication-failed-for-user
https://stackoverflow.com/questions/2942485/psql-fatal-ident-authentication-failed-for-user-postgres

1 — A few dumb questions

  • Are you connecting to a local or remote database? Because if it's remote database, there are some configuration to do on Postgres.
  • Do you have multiple versions and/ or Postgres servers running?
  • Is localhost pointing to 127.0.0.1? (try to ping localhost and see if it is finding or not the IP address of localhost).

2 — What about connecting to it from shell

Can you try to connect to saleor through a shell to see if you manage to connect to it? For that, you can run the bellow command:

psql postgresql://saleor:[email protected]:5432/saleor

3 — Note

Also, why are you running Saleor as root? (you should not do that for safety purposes).

1-
-I am using a remote server but the database is local in the server.
-I suppose i do. When i check from the terminal with postgres -V i get 9.2.23 but when i check the folders i have a directory such /usr/bin/pgsql-10

2-
Connecting from shell also did not work. I did get the same error.
[saleor@site ~]$ psql postgresql://saleor:[email protected]:5432/saleor psql: FATAL: Ident authentication failed for user "saleor"
After this i recreated the user and the database and tried again result is the same.

3-
Thank you for the response and the note. I am now working on another user. I trying to figure things out. Any help is appreciated.

Maybe you are both running Postgres 9.2 and 10? Try:

psql postgresql://saleor:[email protected]:5433/saleor

As Postgres 10 is listening on the port 5433 by default.

I get this now
[saleor@site ~]$ psql postgresql://saleor:[email protected]:5433/saleor psql: could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5433?

I suppose this means that v10 is not running ?

It should be :+1:

Let's try to force the password of the database user saleor to be saleor.
As root, run (copy/paste):

psql postgres postgres <<EOF
ALTER USER saleor WITH ENCRYPTED PASSWORD 'saleor';
\q
EOF

If the console prints:

ERROR:  role "saleor" does not exist

Recreate the user (run as root, or as postgres (sudo -sHu postgres)):

createuser -U postgres -s --pwprompt saleor

Because I suspect that it may have failed previously as it may have been run as root and not as postgres. But I think it depends on the Linux distributions sometimes.

psql: FATAL: Peer authentication failed for user "postgres"

As root?

Yes

Try to login to postgres's shell, using and running:

sudo -sHu postgres
cd
psql <<EOF
ALTER USER saleor WITH ENCRYPTED PASSWORD 'saleor';
\q
EOF

Did get the response:ALTER ROLE

Perfect. Retry to login, whether through

# don't forget to set and export SECRET_KEY
python manage.py migrate

or

psql postgresql://saleor:[email protected]:5432/saleor

Still the same error :
psql: FATAL: Ident authentication failed for user "saleor"

Could it be because of what akjanik mentioned. I tried editing postgresql.conf changing IDENT to md5 but did not do the job. But i also realized i changed the file in the directory /var/lib/pgsql/10/data so i think i should find the directory for 9.2.23

You can try that.
If it works, it is really weird as it should be md5 by default for localhost (in my experience). Maybe it varies in some distributions.

But the weird thing is there is no 9.2.23 only 10 under /var/lib/pysql Is there another possible location it might have been installed.

They may have moved that under /var/lib in 10.0, try to take a look around /etc/postgresql/.

So i solved it with adding this code host all all 127.0.0.1/32 trust to /var/lib/pgsql/data/pg_hba.conf

I know its not save to use trust as auth method. But since this is a development environment i suppose its okay for now.
Should i use md5 instead of trust when i deploy my project ?

Also thanks for the help, much appreciated.

As you think is the best for your case.

host all all 127.0.0.1/32 trust allows any user from 127.0.0.1 to connect to any roles and any databases without asking for the password.

host all all 127.0.0.1/32 md5 allows any user from 127.0.0.1 to connect to any roles and any databases with a valid password.

saleor=> \q
(saleor-master) [saleor@localhost saleor-master]$ vi ./saleor/settings.py
(saleor-master) [saleor@localhost saleor-master]$ psql postgres://saleor:saleor@localhost:5432/saleor
psql: FATAL: Ident authentication failed for user "saleor"
(saleor-master) [saleor@localhost saleor-master]$ psql postgresql://saleor:saleor@localhost:5432/saleor
psql: FATAL: Ident authentication failed for user "saleor"
(saleor-master) [saleor@localhost saleor-master]$ psql postgres://saleor:[email protected]:5432/saleor
psql (9.2.24)
Type "help" for help.

@hetendra Sounds like you're using an older version of Python. Saleor requires Python 3.8.

Done brother, I have updated it to 3.8 and now it's saying no module named
celery, even after I have installed it manually by pip3 install celery.

On Tue, May 5, 2020, 11:45 AM Marcin Gębala notifications@github.com
wrote:

@hetendra https://github.com/hetendra Sounds like you're using an older
version of Python. Saleor requires Python 3.8.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/mirumee/saleor/issues/2209#issuecomment-623874397,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AJBJ2ECV24THYYZZP6HWCWLRP6VIJANCNFSM4FBNIYHQ
.

I am getting the following error-
`Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 308, in execute
settings.INSTALLED_APPS
File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 961, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 783, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/johny/django/saleor-master/saleor/__init__.py", line 1, in
from .celeryconf import app as celery_app
File "/home/johny/django/saleor-master/saleor/celeryconf.py", line 3, in
from celery import Celery
ModuleNotFoundError: No module named 'celery'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 308, in execute
settings.INSTALLED_APPS
File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 961, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 783, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/johny/django/saleor-master/saleor/__init__.py", line 1, in
from .celeryconf import app as celery_app
File "/home/johny/django/saleor-master/saleor/celeryconf.py", line 3, in
from celery import Celery
ModuleNotFoundError: No module named 'celery'`

Was this page helpful?
0 / 5 - 0 ratings