Tutor E-Commerce: Server error

Hi,

I have an issue after enabling the ecommerce plugin.

After I enabled the plugin, saved the config and do tutor local launch, I got “Server Error” while trying to access the webpage at: https://ecommerce.mylms

Below is what I got when after running: tutor local logs --tail=100 ecommerce

Thanks

~$ tutor local logs --tail=100 ecommerce
docker compose -f /home/ubuntu/.local/share/tutor/env/local/docker-compose.yml -f /home/ubuntu/.local/share/tutor/env/local/docker-compose.prod.yml -f /home/ubuntu/.local/share/tutor/env/local/docker-compose.override.yml --project-name tutor_local logs --tail 100 ecommerce
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 33, in inner
tutor_local-ecommerce-1  |     return func(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 259, in cursor
tutor_local-ecommerce-1  |     return self._cursor()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 235, in _cursor
tutor_local-ecommerce-1  |     self.ensure_connection()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 33, in inner
tutor_local-ecommerce-1  |     return func(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
tutor_local-ecommerce-1  |     self.connect()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
tutor_local-ecommerce-1  |     raise dj_exc_value.with_traceback(traceback) from exc_value
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
tutor_local-ecommerce-1  |     self.connect()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 33, in inner
tutor_local-ecommerce-1  |     return func(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 200, in connect
tutor_local-ecommerce-1  |     self.connection = self.get_new_connection(conn_params)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 33, in inner
tutor_local-ecommerce-1  |     return func(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 234, in get_new_connection
tutor_local-ecommerce-1  |     connection = Database.connect(**conn_params)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/__init__.py", line 84, in Connect
tutor_local-ecommerce-1  |     return Connection(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 179, in __init__
tutor_local-ecommerce-1  |     super(Connection, self).__init__(*args, **kwargs2)
tutor_local-ecommerce-1  | django.db.utils.OperationalError: (1045, "Access denied for user 'ecommerce'@'172.18.0.14' (using password: YES)")
tutor_local-ecommerce-1  | 2023-07-05 17:20:22,580 ERROR 11 [django.request] /openedx/venv/lib/python3.8/site-packages/django/utils/log.py:224 - Internal Server Error: /favicon.ico
tutor_local-ecommerce-1  | Traceback (most recent call last):
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
tutor_local-ecommerce-1  |     self.connect()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 33, in inner
tutor_local-ecommerce-1  |     return func(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 200, in connect
tutor_local-ecommerce-1  |     self.connection = self.get_new_connection(conn_params)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 33, in inner
tutor_local-ecommerce-1  |     return func(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 234, in get_new_connection
tutor_local-ecommerce-1  |     connection = Database.connect(**conn_params)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/__init__.py", line 84, in Connect
tutor_local-ecommerce-1  |     return Connection(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 179, in __init__
tutor_local-ecommerce-1  |     super(Connection, self).__init__(*args, **kwargs2)
tutor_local-ecommerce-1  | MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'ecommerce'@'172.18.0.14' (using password: YES)")
tutor_local-ecommerce-1  | 
tutor_local-ecommerce-1  | The above exception was the direct cause of the following exception:
tutor_local-ecommerce-1  | 
tutor_local-ecommerce-1  | Traceback (most recent call last):
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
tutor_local-ecommerce-1  |     response = get_response(request)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/deprecation.py", line 116, in __call__
tutor_local-ecommerce-1  |     response = self.process_request(request)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/contrib/sites/middleware.py", line 12, in process_request
tutor_local-ecommerce-1  |     request.site = get_current_site(request)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/contrib/sites/shortcuts.py", line 13, in get_current_site
tutor_local-ecommerce-1  |     return Site.objects.get_current(request)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django_sites_extensions/models.py", line 43, in patched_get_current
tutor_local-ecommerce-1  |     return self._get_site_by_request(request)  # pylint: disable=protected-access
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django_sites_extensions/models.py", line 95, in patched_get_site_by_request
tutor_local-ecommerce-1  |     site = self.get(domain__iexact=host)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
tutor_local-ecommerce-1  |     return getattr(self.get_queryset(), name)(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 431, in get
tutor_local-ecommerce-1  |     num = len(clone)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 262, in __len__
tutor_local-ecommerce-1  |     self._fetch_all()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 1324, in _fetch_all
tutor_local-ecommerce-1  |     self._result_cache = list(self._iterable_class(self))
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 51, in __iter__
tutor_local-ecommerce-1  |     results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1173, in execute_sql
tutor_local-ecommerce-1  |     cursor = self.connection.cursor()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 33, in inner
tutor_local-ecommerce-1  |     return func(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 259, in cursor
tutor_local-ecommerce-1  |     return self._cursor()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 235, in _cursor
tutor_local-ecommerce-1  |     self.ensure_connection()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 33, in inner
tutor_local-ecommerce-1  |     return func(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
tutor_local-ecommerce-1  |     self.connect()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
tutor_local-ecommerce-1  |     raise dj_exc_value.with_traceback(traceback) from exc_value
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
tutor_local-ecommerce-1  |     self.connect()
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 33, in inner
tutor_local-ecommerce-1  |     return func(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 200, in connect
tutor_local-ecommerce-1  |     self.connection = self.get_new_connection(conn_params)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 33, in inner
tutor_local-ecommerce-1  |     return func(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 234, in get_new_connection
tutor_local-ecommerce-1  |     connection = Database.connect(**conn_params)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/__init__.py", line 84, in Connect
tutor_local-ecommerce-1  |     return Connection(*args, **kwargs)
tutor_local-ecommerce-1  |   File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 179, in __init__
tutor_local-ecommerce-1  |     super(Connection, self).__init__(*args, **kwargs2)
tutor_local-ecommerce-1  | django.db.utils.OperationalError: (1045, "Access denied for user 'ecommerce'@'172.18.0.14' (using password: YES)")
tutor_local-ecommerce-1  | [pid: 11|app: 0|req: 25/63] 172.18.0.4 () {58 vars in 2986 bytes} [Wed Jul  5 17:20:22 2023] GET /favicon.ico => generated 1924 bytes in 20 msecs (HTTP/1.1 500) 4 headers in 153 bytes (1 switches on core 0)

I have the same issue

After enabling the plugin and saving the config, run tutor local do init --limit=ecommerce. It will run all jobs/tasks necessary to run e-commerce smoothly.

1 Like

Thanks for response. Even after running the above, still getting error in log:

docker compose -f /home/openedx/.local/share/tutor/env/local/docker-compose.yml -f /home/openedx/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local logs --follow --tail 0 ecommerce
ecommerce-1  | 2024-07-11 01:58:40,188 ERROR 7 [django.request] /openedx/venv/lib/python3.12/site-packages/django/utils/log.py:224 - Internal Server Error: /complete/edx-oauth2/
ecommerce-1  | Traceback (most recent call last):
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connection.py", line 174, in _new_conn
ecommerce-1  |     conn = connection.create_connection(
ecommerce-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/util/connection.py", line 95, in create_connection
ecommerce-1  |     raise err
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection
ecommerce-1  |     sock.connect(sa)
ecommerce-1  | ConnectionRefusedError: [Errno 111] Connection refused
ecommerce-1  |
ecommerce-1  | During handling of the above exception, another exception occurred:
ecommerce-1  |
ecommerce-1  | Traceback (most recent call last):
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 715, in urlopen
ecommerce-1  |     httplib_response = self._make_request(
ecommerce-1  |                        ^^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 404, in _make_request
ecommerce-1  |     self._validate_conn(conn)
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 1058, in _validate_conn
ecommerce-1  |     conn.connect()
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connection.py", line 363, in connect
ecommerce-1  |     self.sock = conn = self._new_conn()
ecommerce-1  |                        ^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connection.py", line 186, in _new_conn
ecommerce-1  |     raise NewConnectionError(
ecommerce-1  | urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x788c0b0c2240>: Failed to establish a new connection: [Errno 111] Connection refused
ecommerce-1  |
ecommerce-1  | During handling of the above exception, another exception occurred:
ecommerce-1  |
ecommerce-1  | Traceback (most recent call last):
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/requests/adapters.py", line 486, in send
ecommerce-1  |     resp = conn.urlopen(
ecommerce-1  |            ^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 799, in urlopen
ecommerce-1  |     retries = retries.increment(
ecommerce-1  |               ^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/util/retry.py", line 592, in increment
ecommerce-1  |     raise MaxRetryError(_pool, url, error or ResponseError(cause))
ecommerce-1  | urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='my.host.name', port=443): Max retries exceeded with url: /oauth2/access_token (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x788c0b0c2240>: Failed to establish a new connection: [Errno 111] Connection refused'))
ecommerce-1  |
ecommerce-1  | During handling of the above exception, another exception occurred:
ecommerce-1  |
ecommerce-1  | Traceback (most recent call last):
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/social_core/backends/base.py", line 243, in request
ecommerce-1  |     response = request(method, url, *args, **kwargs)
ecommerce-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/requests/api.py", line 59, in request
ecommerce-1  |     return session.request(method=method, url=url, **kwargs)
ecommerce-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
ecommerce-1  |     resp = self.send(prep, **send_kwargs)
ecommerce-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
ecommerce-1  |     r = adapter.send(request, **kwargs)
ecommerce-1  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/requests/adapters.py", line 519, in send
ecommerce-1  |     raise ConnectionError(e, request=request)

tutor version 18.1.1

tutor plugins list
NAME STATUS VERSION
android installed 18.0.0
cairn :white_check_mark: enabled 18.0.0
credentials installed 18.0.0
discovery :white_check_mark: enabled 18.0.0
ecommerce :white_check_mark: enabled 18.0.0
forum :white_check_mark: enabled 18.0.0
indigo :white_check_mark: enabled 18.0.0
jupyter installed 18.0.0
mfe :white_check_mark: enabled 18.0.0
minio :white_check_mark: enabled 18.0.0
myecommerce :white_check_mark: enabled /home/openedx/.local/share/tutor-plugins/myecommerce.py
notes :white_check_mark: enabled 18.0.0
webui :white_check_mark: enabled 18.0.0
xqueue installed 18.0.0

I’ve noticed the URL is getting this redirect at the end: https://my.host.name/complete/edx-oauth2/?redirect_state=OCrC…
see also [10443]

Hello @Ievgenii_Vasiuk, can u try restarting the ecommerce service by running

tutor local stop ecommerce && tutor local start -d

Hi @FarazM unfortunately it did not helped or just partially - now log shows this error:

ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/social_core/backends/oauth.py", line 99, in validate_state
ecommerce-1  |     raise AuthMissingParameter(self, "state")
ecommerce-1  | social_core.exceptions.AuthMissingParameter: Missing needed parameter state
ecommerce-1  | 2024-07-12 04:21:36,807 ERROR 7 [django.request] /openedx/venv/lib/python3.12/site-packages/django/utils/log.py:224 - Internal Server Error: /complete/edx-oauth2/
ecommerce-1  | Traceback (most recent call last):
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 47, in inner
ecommerce-1  |     response = get_response(request)
ecommerce-1  |                ^^^^^^^^^^^^^^^^^^^^^

and later this:

ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection
ecommerce-1  |     sock.connect(sa)
ecommerce-1  | ConnectionRefusedError: [Errno 111] Connection refused
ecommerce-1  |
ecommerce-1  | During handling of the above exception, another exception occurred:
ecommerce-1  |
ecommerce-1  | Traceback (most recent call last):
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 715, in urlopen
ecommerce-1  |     httplib_response = self._make_request(
ecommerce-1  |                        ^^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 404, in _make_request
ecommerce-1  |     self._validate_conn(conn)
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 1058, in _validate_conn
ecommerce-1  |     conn.connect()
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connection.py", line 363, in connect
ecommerce-1  |     self.sock = conn = self._new_conn()
ecommerce-1  |                        ^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connection.py", line 186, in _new_conn
ecommerce-1  |     raise NewConnectionError(
ecommerce-1  | urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x743f3c4b1f70>: Failed to establish a new connection: [Errno 111] Connection refused
ecommerce-1  |
ecommerce-1  | During handling of the above exception, another exception occurred:
ecommerce-1  |
ecommerce-1  | Traceback (most recent call last):
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/requests/adapters.py", line 486, in send
ecommerce-1  |     resp = conn.urlopen(
ecommerce-1  |            ^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 799, in urlopen
ecommerce-1  |     retries = retries.increment(
ecommerce-1  |               ^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/util/retry.py", line 592, in increment
ecommerce-1  |     raise MaxRetryError(_pool, url, error or ResponseError(cause))
ecommerce-1  | urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='my.host.name', port=443): Max retries exceeded with url: /oauth2/access_token (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x743f3c4b1f70>: Failed to establish a new connection: [Errno 111] Connection refused'))
ecommerce-1  |
ecommerce-1  | During handling of the above exception, another exception occurred:
ecommerce-1  |
ecommerce-1  | Traceback (most recent call last):
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/social_core/backends/base.py", line 243, in request
ecommerce-1  |     response = request(method, url, *args, **kwargs)
ecommerce-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/requests/api.py", line 59, in request
ecommerce-1  |     return session.request(method=method, url=url, **kwargs)

Looks like I’ve figured it out, here is what I’ve found:
If you see the screen below (NotFond) when you try to navigate to the Ecommerce site then be aware that this, believe it or not, is correct.
-thanks to this blog: Open edX Ecommerce - Blog

I’ve re-created superuser by “tutor local run ecommerce ./manage.py createsuperuser”
(as noted here: Overhang.IO | Tutor Plugins - ecommerce) and was able to login at https://ecommerce.my.host.url/admin/ I believe that means that my setup is fine.

I’m still struggling to enable selling access to courses - the “Upgrade” button is disabled on the courses.

P.S. I wonder if chances are to make “enable selling access” working at all at Tutor 18.1.1 and ecommerce 18.0.0
-Based on WARNING at GitHub - overhangio/tutor-ecommerce: Ecommerce plugin for Tutor
e-commerce and e-commerce worker are under-maintained. The Open edX community is not fixing bugs or developing new features for it. We hope to deprecate and replace it soon.

Version 17.0.0 is listed at E-commerce Plugin | Tutor, maybe makes sense trying to downgrade e-commerce plugin from v 18 to 17 to make it working?