Skip to content

Cant get MAS work in element X ios #5163

@Sinterdial

Description

@Sinterdial

Describe the bug
I've already set up my self-hosted Synapse and MAS, and everything works fine on the web and desktop clients — they can correctly redirect to the MAS website.
However, when I try to log in to my self-hosted server using Element X on iPhone or Android, it fails to redirect properly and shows the message:
“Your homeserver needs to be upgraded to support Matrix Authentication Service and account creation.”

What’s special about my setup is that my Synapse instance isn’t running on a standard port — meaning my homeserver name and various URIs all include the domain name plus a port number. I’m not sure if that’s what’s causing the issue.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Element X'
  2. Click on 'Create Account'
  3. Chose 'Change account provider'
  4. Insert my synapse server url
  5. Click on 'Continue'
  6. See error**“Your homeserver needs to be upgraded to support Matrix Authentication Service and account creation.”**

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [Windows 11 24H2]
  • Browser [Selfhosted element-web ]
  • Version [v1.12.0]

Smartphone (please complete the following information):

  • Device: [iPhone 16 Pro]
  • OS: [iOS 26]
  • Browser [chrome]
  • Version [25.10.0]

Additional context
My setup environment: Docker (Portainer CE)
The Synapse container reports an error:

2025-10-18 15:08:40,145 - synapse.http.client - 454 - INFO - GET-413 - Received response to GET http://matrix-auth-service:8094/.well-known/openid-configuration: 502
2025-10-18 15:08:39,968 - synapse.access.http.8008 - 515 - INFO - GET-412 - 192.168.5.25 - 8008 - {None} Processed request: 0.000sec/0.000sec (0.000sec, 0.000sec) (0.000sec/0.000sec/0) 49B 200 "GET /_matrix/federation/v1/version HTTP/1.1" "Element X/25.10.0 (iPhone 16 Pro; iOS 26.0.1; Scale/3.00)" [0 dbevts]
2025-10-18 15:08:40,145 - synapse.http.server - 151 - ERROR - GET-413 - Failed handle request via 'AuthMetadataServlet': <XForwardedForRequest at 0x14cb3bb5c920 method='GET' uri='/_matrix/client/unstable/org.matrix.msc2965/auth_metadata' clientproto='HTTP/1.1' site='8008'>
    callback_return = await self._async_render(request)
Traceback (most recent call last):
    raise self.value.with_traceback(self.tb)
2025-10-18 15:08:40,145 - synapse.http.client - 454 - INFO - GET-413 - Received response to GET http://matrix-auth-service:8094/.well-known/openid-configuration: 502
  File "/usr/local/lib/python3.12/site-packages/synapse/http/server.py", line 339, in _async_render_wrapper
  File "/usr/local/lib/python3.12/site-packages/synapse/http/server.py", line 564, in _async_render
  File "/usr/local/lib/python3.12/site-packages/synapse/rest/client/auth_metadata.py", line 99, in on_GET
    callback_return = await raw_callback_return
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return 200, await self._auth.auth_metadata()
    metadata = await self._server_metadata.get()
  File "/usr/local/lib/python3.12/site-packages/synapse/api/auth/mas.py", line 172, in auth_metadata
  File "/usr/local/lib/python3.12/site-packages/synapse/util/caches/cached_call.py", line 143, in get
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/synapse/util/caches/cached_call.py", line 113, in get
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return await self._cachedcall.get()
    self._result.raiseException()
  File "/usr/local/lib/python3.12/site-packages/twisted/python/failure.py", line 455, in raiseException
  File "/usr/local/lib/python3.12/site-packages/twisted/internet/defer.py", line 1857, in _inlineCallbacks
    result = context.run(gen.send, result)
  File "/usr/local/lib/python3.12/site-packages/synapse/util/caches/cached_call.py", line 133, in _wrapper
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           ^^^^^^^^^
    return await f()
    response = await self._http_client.get_json(self._metadata_url)
  File "/usr/local/lib/python3.12/site-packages/synapse/api/auth/mas.py", line 159, in _load_metadata
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    body = await self.get_raw(uri, args, headers=actual_headers)
  File "/usr/local/lib/python3.12/site-packages/synapse/http/client.py", line 603, in get_json
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/synapse/http/client.py", line 695, in get_raw
    raise HttpResponseException(
synapse.api.errors.HttpResponseException: 502: Bad Gateway

The log in MAS container:

2025-10-18T07:08:40.155373Z  INFO http.server.response GET-946 - "GET /_matrix/client/v3/login HTTP/1.1" 200 OK "Element X/25.10.0 (iPhone 16 Pro; iOS 26.0.1; Scale/3.00)" [polls: 0, cpu: 0.0ms, elapsed: 0.0ms]
2025-10-18T07:08:16.788200Z  INFO http.server.response GET-920 - "GET /_matrix/client/v3/login HTTP/1.1" 200 OK "Element X/25.10.0 (vivo V2338A; Android 15; PD2338_A_15.1.13.15.W10.V000L1; Sdk c7b4b5dc0)" [polls: 0, cpu: 0.0ms, elapsed: 0.1ms]
2025-10-18T07:08:56.876982Z  INFO mas_tasks::new_queue:507 worker-run-loop-962 - Sending heartbeat
2025-10-18T07:09:40.907702Z  INFO http.server.response POST-1010 - "POST /oauth2/introspect HTTP/1.1" 200 OK "Synapse/1.139.2" [polls: 7, cpu: 0.3ms, elapsed: 0.9ms]
2025-10-18T07:09:40.903535Z  INFO http.server.response POST-1009 - "POST /oauth2/introspect HTTP/1.1" 200 OK "Synapse/1.139.2" [polls: 7, cpu: 0.3ms, elapsed: 2.8ms]
2025-10-18T07:09:48.176450Z  INFO mas_handlers::activity_tracker::worker:242 Flushing 2 activity records to the database

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions