Running per-course Matrix rooms for Moodle on your own homeserver
Teachers who want course chat without a third-party service can use Moodle's core Matrix communication provider. Moodle 4.3 introduced a Matrix integration in which Matrix is available for use in courses, with admin controls for room creation and moderation capabilities for teachers. The provider is configured with a homeserver name, a homeserver URL used for connecting and creating accounts, and an access token for the account that performs actions on the homeserver, so the rooms live on a homeserver your organization operates rather than on a hosted service.
The integration covers the Moodle side only. Moodle creates and manages course rooms, synchronizes membership from course enrolments and gives teachers moderation capabilities. It does not run the homeserver, handle federation policy, provide the Matrix clients people use on their devices, or manage message retention and backups. Those belong to the homeserver, and the choice of homeserver is a separate decision from the Moodle configuration. Synapse is the most widely documented option, developed by Element and distributed under AGPL-3.0, but Dendrite and Conduit-family servers are also listed on the Matrix.org ecosystem page, so confirm which implementation the provider is tested against before you commit to one.
Before you configure anything, decide who owns the access token account, how it is provisioned and rotated, and whether the homeserver will allow federation at all. Ask your Moodle partner to confirm the Moodle version and the provider's current behaviour for account creation on your chosen homeserver, and plan a test course with a small set of enrolled users to check membership sync and teacher moderation before rollout.
What the Matrix course rooms integration needs before setup
The Matrix provider in Moodle depends on decisions made before anyone opens the admin settings: which Moodle release you run, which homeserver you operate, how users and rooms are named, and how Moodle authenticates to the homeserver. Each card below is a prerequisite that is hard to change later, so settle it in the planning stage.
Moodle release and server requirements
The Matrix communication provider arrived in Moodle 4.3, so any site older than that cannot use it. Moodle 5.1 requires 64-bit PHP 8.2 or later (8.3 and 8.4 are supported) and PostgreSQL 15, MySQL 8.4, MariaDB 10.11 or SQL Server 2017 or later. Moodle 5.3 raises the floor to PHP 8.3, PostgreSQL 17, MariaDB 11.4 or SQL Server 2019. Check which release you will run before choosing database versions, and confirm the Matrix provider's current settings in your exact Moodle version.
Moodle 5.3 notesSelf-hosted homeserver choice
Synapse is the most documented homeserver and is developed by Element under AGPL-3.0, so confirm that its licence terms suit your organization before you deploy it. Dendrite, Conduit and its forks Continuwuity and Tuwunel are alternatives, but check each one's support for the Moodle provider's account creation and room actions before committing. Your homeserver choice determines the upgrade path and the operations skills your team needs.
Synapse docsPostgreSQL and Python runtime
Synapse recommends PostgreSQL for production, with SQLite also supported. Recent Synapse releases require PostgreSQL 14 or newer and Python 3.10 or newer. Plan database backups and the upgrade order together, because Synapse's upgrade notes warn that rolling back can be difficult after schema changes, and that support is dropped when Python or PostgreSQL reach upstream end of life.
Synapse upgrade notesServer name and DNS plan
The server_name setting fixes how user IDs such as @user:example.com and room IDs are identified, and changing it later is effectively a rebuild. Decide whether the Matrix domain matches your main domain or uses a dedicated one, and set delegation so that identifiers can be served from another host on port 443. Confirm the DNS records and the host that Moodle will call as the homeserver URL before the first course room is created.
TLS and reachable endpoints
Moodle connects to the homeserver URL over HTTPS, and clients and federation peers need valid certificates on the names you publish. Plan the certificate issuer, renewal, and whether the homeserver is reachable from the Moodle web servers, from student devices, or from both. Synapse federates on port 8448 by default, so decide whether that listener is exposed at all before you configure federation.
Federation policy decision
Federation lets your users talk to people on other homeservers, which is rarely wanted for course rooms that hold student data. Synapse's federation_domain_whitelist restricts federation to listed domains, and an empty list disables it. Decide the policy with your privacy and compliance owners, then firewall the federation listener to match, because the documentation recommends that step in addition to the setting.
Dedicated service account and access token
Moodle performs room and account actions through one homeserver account, identified by an access token. Create a dedicated service account rather than reusing a staff login, restrict who can read the token in Moodle's configuration, and record a rotation procedure. Document which account creates rooms and who may revoke the token if a course room is misused.
Configuration sequence from homeserver to first course room
This sequence takes a Matrix homeserver you control from first deployment to a working chat room for one Moodle course, with each step confirmed before the next begins. The order matters because Moodle needs a reachable homeserver, a working account and a valid token before any room can be created or synchronized.
Deploy and name the homeserver
The platform or infrastructure team deploys a Synapse homeserver in infrastructure you control, using PostgreSQL for production as the upstream documentation recommends. Set server_name to the domain you intend to keep, because it fixes how user IDs and room IDs are identified and is difficult to change later. Confirm the homeserver answers on its client URL over HTTPS and that a test client can log in with a locally created user. Do not proceed until that login succeeds.
Set the federation policy
Decide whether this homeserver should talk to other servers at all. For a closed course-chat setup, set federation_domain_whitelist to the domains you list, or to an empty list to disable federation entirely, and firewall the federation listener as the Synapse configuration manual recommends. Federation runs on port 8448 by default, so check whether your network needs that port open. Confirm the policy by testing from an outside server that a non-listed domain cannot join or be joined.
Create the service account and access token
Create a dedicated Matrix account for Moodle to act as, separate from any teacher or administrator account, and generate its access token. Moodle uses this account to create the rooms and manage membership, so its permissions define what Moodle can do on the homeserver. Confirm the token works by calling a read-only endpoint, such as fetching the account's own profile, with the token and no password. Record where the token is stored so it can be rotated later.
Enable the Matrix provider in Moodle
A Moodle administrator enables the communication Matrix provider and enters the homeserver name, the homeserver URL used for connecting and creating accounts, and the access token from the previous step. Save the settings, then check that the provider reports a successful connection. If the connection fails, verify that the Moodle server can reach the homeserver URL, since the connection is made from Moodle's side and not from a user's browser. Confirm the check passes before configuring room behavior.
Set admin controls for room creation
The Moodle administrator sets which roles and course contexts can have Matrix rooms created, and decides whether room creation is automatic per course or requested by a teacher. Document these choices so the security or compliance owner can review who may create rooms and under what conditions. Confirm the settings by reviewing them with a test account that lacks the rights, which should be unable to create a room. Keep the settings written down for the change record.
Grant teacher moderation capabilities
Assign the Moodle capabilities that let teachers moderate their course room, such as managing members and removing messages, and confirm they apply only in course context. Check the exact capability names against the Moodle 4.3 release notes and the communication Matrix language strings in your installed version, because the names and their effect should be confirmed in your environment before rollout. Confirm the grant by logging in as a teacher test user and checking that the moderation controls appear for their course and not for other courses.
Test one course room end to end
Create a test course with a test teacher and two test students, then enable the Matrix chat for that course and confirm a room is created on the homeserver. Enrol a new student and check that the student appears as a member of the room, then unenrol them and confirm removal. Send messages as each test user to confirm they appear for the right members. This membership change after enrolment is the proof that the synchronization works, so do not roll out to live courses until it does.
How a course enrolment becomes a Matrix room membership
The flow starts when a teacher or enrolment method adds a user to a Moodle course. The Matrix communication provider then calls the homeserver URL with the service account access token, creating accounts and joining the matching course room on your Synapse server. Moodle holds the course roster and the token, while the homeserver holds rooms and memberships, so the trust boundary between them is where you should check token scope and network access. The federation listener is optional and sits apart from this path.
Enrolment events flow through the Matrix provider to the homeserver, across a trust boundary.
How Moodle roles and enrolments map to Matrix room membership
This table compares how each Moodle role or enrolment event is expected to affect a course room's Matrix membership and power level, and the server name that identifies those users. Read it as a planning baseline: the exact sync behaviour depends on the communication_matrix provider code and your Moodle version, so confirm each row in a test course before rollout.
| Moodle event | Expected Matrix effect | What to confirm |
|---|---|---|
| Teacher enrolled in course | Account is invited or joined to the course room with moderator-level power | Exact power level granted in the provider code for your Moodle version |
| Student enrolled in course | Account is invited or joined to the course room as a regular member | Whether invitations are sent or users join directly |
| Manager or other elevated role | Membership depends on whether the role is mapped to the room at all | Whether non-teacher roles receive any room membership by default |
| Matrix IDs in the room | Users appear as @username:server_name on your homeserver | The server_name value must match the homeserver configuration before accounts are created |
| Student enrolment removed | Expected to remove room membership on next sync | Timing of the sync task and whether history stays visible to the removed user |
| Course suspended or enrolment suspended | Expected to change access to the room, possibly by removing membership | Whether suspension triggers the same removal path as unenrolment |
| Teacher role removed | Power level expected to drop to member level | Whether moderation rights are revoked on the next sync or manually |
| Account suspended in Moodle | Matrix account is not automatically deactivated by course sync | Whether a separate account deactivation process is needed on the homeserver |
Securing the homeserver and the Moodle service account
The Matrix provider in Moodle holds a privileged account on your homeserver, and the homeserver itself is reachable by other servers unless you restrict it. The cards below cover the token Moodle uses, the federation boundary, identity naming, licensing and patching, which together decide how much damage a single compromise or misconfiguration can do.
Scope the Moodle access token
Moodle authenticates to the homeserver with an access token for one account that creates rooms, invites members and moderates. Treat that account as a service account: give it its own localpart, do not use an administrator's personal login, and confirm which admin-level permissions the Matrix provider actually needs before granting any. Ask your Moodle administrator which capabilities the provider calls and document them, so a reviewer can tie each permission to a feature.
Store and rotate the token
The access token is a bearer credential, so anyone who reads it can act as the Moodle account. Keep it out of web-accessible configuration and version control, restrict who can view the Moodle admin settings where it is entered, and log every change. Agree a rotation procedure with the Matrix administrators before go-live, including how the token is revoked and replaced without breaking course rooms that are already running.
Restrict federation to an allow list
Synapse federates with other homeservers by default, so course rooms could be reachable from outside your organization. Set federation_domain_whitelist to the domains you actually need, or to an empty list if course chat must stay on your server. The configuration manual notes that an empty list disables federation, which is the stricter choice for most course use. Confirm the decision with your privacy office before rooms are created.
Firewall the federation listener
Synapse's federation listener uses port 8448 by default. The Synapse docs recommend firewalling this listener in addition to the allow list, because a list is only enforced by the application and a network rule limits exposure even if configuration drifts. Decide whether the listener is reachable at all, and if it is, restrict it to the peers you have approved. Verify the rule from outside your network, not only from the server.
Synapse federation docsChoose server_name and delegation early
The server_name setting fixes how user IDs such as @user:example.com and room identifiers are written, and changing it later effectively creates a new identity space. Pick the domain your organization will keep for years. If the homeserver runs on a different host, delegation lets user IDs keep the clean domain while federation and client traffic go elsewhere on port 443. Confirm DNS ownership and the delegation records with your network team before the first user is created.
Meet the AGPL-3.0 obligations
Synapse is distributed under AGPL-3.0, and Element sells commercial licenses as an alternative. Under AGPL, if you modify Synapse and users interact with it over a network, you must offer them the source of your modifications. Using unmodified upstream Synapse with a Moodle integration usually keeps this simple, but any custom patches or forks change the obligation. Ask your legal team to confirm whether the AGPL terms or a commercial license fit your use before you deploy.
Patch Moodle and Synapse on supported lines
Both products need regular updates, and each has its own support window. Moodle 5.1 has security support until 19 April 2027 and Moodle 5.2 until 4 October 2027, while 4.5 LTS has security support until 4 October 2027. Synapse drops support for Python and PostgreSQL versions once upstream ends their life, and its upgrade notes warn that rollback can be hard because of schema changes. Test each upgrade in staging and take a database backup first.
Moodle releasesDeciding whether course rooms should federate
The first decision for Moodle course rooms is whether your Matrix homeserver should talk to other homeservers at all. A closed homeserver keeps every course room, membership list and message on your own server and only lets your users reach each other. Federation lets your users join rooms hosted elsewhere and lets people on other servers join your rooms, which suits some institutions and is unacceptable for others. Neither answer is correct for every organization, so settle it before the first course room is created, because changing it later means reviewing rooms and accounts that already hold student conversations.
In Synapse, the setting that controls this is federation_domain_whitelist in the configuration file. An empty list disables federation entirely, while a list of named domains restricts federation to those servers. The Synapse documentation also recommends firewalling the federation listener, which defaults to port 8448, so that the server setting and the network rule agree. If you use delegation, so that user IDs such as @user:example.com are served from a different host on port 443, confirm that the delegation records and the server_name value match what your privacy and records teams have approved. Confirm each of these in your own environment rather than assuming the defaults.
Let your privacy, safeguarding and records policies decide the question, and write the answer down. Ask whether student messages in course rooms are education records under your jurisdiction, whether minors can be contacted by people outside your institution, and who must be able to retrieve or delete a conversation on request. Federation means your retention and deletion controls only cover data on your server, so a message copied into a remote room may outlive your policy. A closed server or a short domain allow list usually makes these questions easier to answer, but it also limits contact with external experts, partner institutions and other courses that may need shared spaces.
If you decide to federate, record the allowed domains, who approves additions to the list, and how a remote room is reviewed when a safeguarding concern arises. If you do not, record how users will be kept in contact with people outside the server and who handles those requests. Check the Moodle side as well: the Matrix provider in Moodle creates and moderates rooms through the homeserver, so the federation decision also determines what teachers can expect when they create a room. Review the Synapse configuration manual with your security and legal reviewers before the decision is signed off.
Common Matrix course room failures and their fixes
This table lists the failures most likely to appear when Moodle course rooms run on a self-hosted Matrix homeserver, with the usual cause and fix for each. Read it as a triage guide: match the symptom you see first, then check the cause column before changing settings. Confirm exact behavior against your Moodle version and Synapse release notes.
| Failure | Likely cause | Fix |
|---|---|---|
| Provider cannot reach the homeserver URL | The homeserver URL in the provider settings is wrong, the address is not reachable from the Moodle web or cron servers, or a proxy or firewall blocks the connection | Test the URL from the Moodle server itself, confirm the scheme and port, and allow outbound access from Moodle to the homeserver client listener |
| Invalid or expired access token | The token was revoked, belongs to an account that was deactivated, or was copied incorrectly into the provider settings | Generate a new token for the dedicated Moodle service account, update the provider setting, and confirm the account still has rights to create rooms |
| Rooms not created for courses | Matrix communication is not enabled for the course or site, the provider is not selected, or room creation is restricted for teachers in admin settings | Check the communication settings at site and course level, confirm the provider is enabled, and review the room creation permissions for teacher roles |
| Membership does not update after enrolment changes | Scheduled tasks are not running, the Moodle service account lacks permission to invite or remove members, or users have no Matrix account on the homeserver | Confirm cron runs, check the service account power level in each room, and verify that enrolled users were created or matched on the homeserver |
| Federation not working when expected | Federation is disabled or restricted by federation_domain_whitelist, server_name or delegation is wrong, or port 8448 or the delegated port 443 route is blocked | Review the federation settings against the intended partner list, verify delegation and the federation listener, and test from an external network |
| Synapse upgrade blocked by database or Python requirements | The current PostgreSQL or Python version is below the minimum in the target release notes, so the upgrade stops before migrations run | Read the upgrade notes for each version between your current and target release, upgrade PostgreSQL and Python first in a staging copy, and take a database backup before the upgrade |
| Upgrade cannot be rolled back cleanly | Database schema changes in the new release make a return to the old version difficult | Take and test a full database backup before upgrading, and treat the staging rehearsal as the only tested rollback path |
Questions buyers ask before setting up Matrix course rooms
What drives the cost of running Matrix course rooms in Moodle?
The cost depends mostly on the homeserver you run, the Moodle administration time needed to connect it, the moderation policy you agree, and the testing before go-live. Each of these is a separate line in a quote. The homeserver is a recurring cost: hosting, database, storage, backups, monitoring and the staff who patch and watch it. Moodle setup is largely one-time: configuring the Matrix communication provider with a homeserver name, a homeserver URL and an access token for the account that acts on the server, then deciding how course rooms are created. Moderation policy and safeguarding rules add review time that recurs each term. Ask any provider to price these components separately, and state which ones are one-time and which recur.
How long does a Matrix course room setup take?
Duration depends on scope, so no single figure applies. The main variables are whether you already run a Synapse or other Matrix homeserver, how many Moodle sites and course categories need rooms, how many identity sources feed membership, and how much moderation and safeguarding policy must be written before go-live. A pilot with one course category and a test homeserver is much shorter than a rollout across all faculties with federation decisions still open. Ask for a written plan with phases, the entry criteria for each phase, and the named client-side tasks that gate progress. Treat any timeline given before the scope is agreed as provisional.
What does our team need to provide for a Matrix course rooms project?
Expect to supply several things before build work starts. You need an identity source that Moodle and the homeserver can both trust, and a decision on whether accounts are created from Moodle or from a central directory. You need DNS records for the homeserver name and the public address, plus delegation if user IDs will use your primary domain. You need TLS certificates for the client and federation endpoints, and firewall rules for the federation listener if it is open. You also need Moodle administrator access to install and configure the provider, and a named owner for safeguarding decisions: who may create rooms, who moderates, what is retained and how students are protected. Confirm each of these with your own infrastructure and policy teams.
Can our in-house team set up Matrix course rooms without a partner?
Yes, if your team already runs Moodle administration and operates a Matrix homeserver, which means database, reverse proxy, certificates and upgrades. The Moodle side is a configured core provider rather than custom code, so the main gap for most teams is homeserver operations and the policy work around moderation and safeguarding. Teams without Synapse experience should check the upgrade notes before choosing a version, because rollback can be difficult after database schema changes. A partner can be useful for the homeserver build, the membership sync design, testing, or a documented handover. Compare the cost of building those skills against the cost of an outside engagement with a written scope.
How does membership sync from course enrolments work, and what can break?
Moodle's Matrix provider is designed so that room membership follows course enrolment, but the exact behavior depends on the Moodle and provider versions you run, so test it on a staging site. Common failures include users who exist in Moodle but have no matching Matrix account, homeserver names that differ between the configuration and the user IDs, access tokens that expire or belong to an account without rights to create rooms, and enrolment changes that arrive while the homeserver is unreachable. Test enrolment, unenrolment, role changes and suspended accounts in a pilot course. Confirm who can see room history after a student leaves the course, since that is a retention and safeguarding question as well as a technical one.
Should course rooms federate with other Matrix servers?
Federation is a policy decision, not a default to accept. Synapse federates on port 8448 by default, and its federation_domain_whitelist setting can restrict federation to listed domains, while an empty list disables it. If rooms must stay inside your institution, disable federation or restrict it, and firewall the federation listener as the documentation recommends. If students must talk to people on other servers, list those domains and record why. Your security and safeguarding teams should sign this decision off in writing before the homeserver goes live, because changing it later affects existing rooms and users.
What changes when we upgrade Moodle or Synapse?
Moodle and Synapse upgrade on different schedules, and each can affect the other. Moodle major releases arrive every six months, with minor point releases in between, and the Matrix provider may change with them. Moodle 5.1 requires PHP 8.2 or later and PostgreSQL 15 or another listed database, and its document root must point to the /public directory. Synapse 1.143.0 and later require PostgreSQL 14 or newer, and 1.142.0 and later require Python 3.10 or newer. Synapse drops support for versions that reach upstream end of life, and the upgrade notes warn that rollback can be difficult because of schema changes. Take a database backup before every Synapse upgrade, test in staging, and check the Moodle release notes for provider changes before each Moodle upgrade.
What licensing should we check before running Synapse for course rooms?
Synapse is distributed under AGPL-3.0, and Element sells commercial licenses as an alternative. Element announced on December 13, 2023 that future Synapse contributions would be licensed under AGPLv3 instead of Apache 2.0. Your legal team should decide whether AGPL obligations fit how you run and modify the homeserver, and whether a commercial license is needed. Other homeserver implementations, including Dendrite, carry AGPL-3.0-or-later terms, while Conduit and its forks are listed under Apache-2.0. Confirm the current license terms with the project and your legal advisers, since they can change.
Keeping Matrix course rooms working across upgrades
Treat the Synapse homeserver and the Moodle Matrix provider as two products that upgrade on different schedules, and plan a rollback path before either one changes. The Synapse upgrade notes warn that rolling back can be difficult because database schema changes between releases may not reverse cleanly. That means a failed Synapse upgrade is usually fixed forward, so the reliable safety net is a verified database backup taken immediately before the change, not a reinstall of the old version. Also check the upstream support policy: Synapse drops support for Python and PostgreSQL versions once they reach upstream end of life, so a planned operating system or database upgrade can force a Synapse upgrade that the chat team did not schedule. Read the current release notes for each Synapse version before you apply it.
Test every Moodle major upgrade against the Matrix provider in a staging copy before production. Moodle's Matrix communication provider talks to the homeserver through the configured homeserver URL and the access token of the service account, so a Moodle upgrade, a PHP change or a new TLS setting can break course room creation or membership sync without any visible error on the course page. Your test should create a course room, enrol a test student and teacher, confirm the teacher can moderate, remove the student, and confirm the room membership follows. Back up the homeserver PostgreSQL database and the media store together, and record the Synapse version, because restoring one without the other can leave room state and uploaded files out of step. Confirm the exact supported version combinations with the Moodle release notes and the Synapse upgrade notes before you set the upgrade window.
Monitor the service account and its access token as carefully as the server itself. If the token expires, is revoked or the account is locked, course rooms stop being created or updated, and teachers may only notice when a new course starts. Alert on failed API calls from Moodle, track the account's login and permission changes, and document who can rotate the token and how it is stored. The workers architecture, where the main process and workers share Redis for replication, exists to scale Synapse for large numbers of users and rooms. A single-host deployment for one institution's courses does not need it, and adding it early adds components to back up, upgrade and monitor. Confirm your expected concurrent user count with the Synapse documentation before deciding.
How DeployOpen scopes and delivers Moodle Matrix course rooms
DeployOpen plans and implements Moodle's core Matrix communication provider on a Matrix homeserver you run in your own infrastructure. We scope the course-room model, configure the provider and membership rules, test moderation and access, and document the result so your own team can operate it after handover.
How we scope
- Agree in writing which courses get rooms, who creates them and who moderates them
- Map course enrolment roles to Matrix room membership and moderation permissions
- Confirm the homeserver choice, server name and whether federation is enabled or disabled
- Define the Matrix access token account, its permissions and how its credentials are stored
How we build
- Deploy the homeserver and database according to the agreed design, with PostgreSQL for production
- Configure Moodle's Matrix provider with the homeserver name, URL and access token
- Set admin controls for room creation and teacher moderation capabilities in Moodle
- Test room creation, enrolment sync, role changes and removals against a staging Moodle site
How we hand over
- Deliver a written configuration record covering homeserver settings, Moodle provider settings and sync rules
- Document the room lifecycle for archiving, ownership changes and manual corrections
- Walk through the upgrade procedure for Moodle and Synapse, including database backup before changes
- Provide a test checklist your administrators can rerun after each platform update
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after handover
- Track Moodle and Synapse release changes and plan upgrades in a scheduled window
- Review federation, access and logging settings again when your policies change
- Confirm support terms and response expectations in the written scope before work starts

