#
Matterbridge launchctl configuration (macOS)
[](https://www.npmjs.com/package/matterbridge)
[](https://www.npmjs.com/package/matterbridge)
[](https://hub.docker.com/r/luligu/matterbridge)
[](https://hub.docker.com/r/luligu/matterbridge)


[](https://codecov.io/gh/Luligu/matterbridge)
[](https://vitest.dev)
[](https://oxc.rs/docs/guide/usage/formatter.html)
[](https://oxc.rs/docs/guide/usage/linter.html)
[](https://www.typescriptlang.org/)
[](https://github.com/microsoft/typescript-go)
[](https://nodejs.org/)
[](https://bun.com)
[](https://matterbridge.io)
[](https://www.npmjs.com/package/matter-history)
[](https://www.npmjs.com/package/node-ansi-logger)
[](https://www.npmjs.com/package/node-persist-manager)
---
# Production configuration
## Run matterbridge as system service with launchctl (macOS) and its own global node_modules directory
### Optional: cleanup all previous setups
```bash
sudo rm -rf ~/Matterbridge
sudo rm -rf ~/.matterbridge
sudo rm -rf ~/.mattercert
sudo rm -rf /usr/local/etc/matterbridge
sudo rm -f /Library/LaunchDaemons/matterbridge.plist
sudo rm -f /var/log/matterbridge.log /var/log/matterbridge.err
sudo npm uninstall matterbridge -g
```
### Verify node setup
```bash
node -v
npm -v
```
It should output something like:
```text
v22.20.0
10.9.3
```
### Check node path
```bash
which node
```
It should output something like:
```text
/usr/local/bin/node
```
### First create the Matterbridge directories
This will create the required directories if they don't exist and install matterbridge in the matterbridge global node_modules directory
```bash
sudo mkdir -p /usr/local/etc/matterbridge
sudo mkdir -p /usr/local/etc/matterbridge/.npm-global
sudo mkdir -p /usr/local/etc/matterbridge/Matterbridge
sudo mkdir -p /usr/local/etc/matterbridge/.matterbridge
sudo mkdir -p /usr/local/etc/matterbridge/.mattercert
sudo chown -R root:wheel /usr/local/etc/matterbridge
sudo chown -R root:wheel /usr/local/etc/matterbridge/.npm-global
sudo chmod -R 755 /usr/local/etc/matterbridge/.npm-global
sudo NPM_CONFIG_PREFIX=/usr/local/etc/matterbridge/.npm-global npm install -g matterbridge --omit=dev
```
### Then create a system launchctl configuration file for Matterbridge
- create a launchctl configuration file for Matterbridge
```bash
sudo nano /Library/LaunchDaemons/matterbridge.plist
```
- add the following to the file:
```text
EnvironmentVariables
PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/etc/matterbridge/.npm-global/bin
NPM_CONFIG_PREFIX
/usr/local/etc/matterbridge/.npm-global
HOME
/var/root
NODE_PATH
/usr/local/etc/matterbridge/.npm-global/lib/node_modules
KeepAlive
Label
matterbridge
ProgramArguments
/usr/local/etc/matterbridge/.npm-global/bin/matterbridge
--homedir
/usr/local/etc/matterbridge
--service
--nosudo
RunAtLoad
StandardErrorPath
/var/log/matterbridge.err
StandardOutPath
/var/log/matterbridge.log
WorkingDirectory
/usr/local/etc/matterbridge
```
- stop matterbridge
```bash
sudo launchctl bootout system/matterbridge
```
- check the plist
```bash
sudo chown root:wheel /Library/LaunchDaemons/matterbridge.plist
sudo chmod 644 /Library/LaunchDaemons/matterbridge.plist
sudo plutil -lint /Library/LaunchDaemons/matterbridge.plist
sudo plutil -convert xml1 /Library/LaunchDaemons/matterbridge.plist
```
- bootstrap matterbridge and enable it
```bash
sudo rm -f /var/log/matterbridge.log /var/log/matterbridge.err
sudo launchctl bootstrap system /Library/LaunchDaemons/matterbridge.plist
sudo launchctl enable system/matterbridge
```
### Start Matterbridge
```bash
sudo launchctl kickstart -k system/matterbridge
```
### Stop Matterbridge
```bash
sudo launchctl bootout system/matterbridge
```
### Restart Matterbridge
```bash
sudo launchctl kickstart -k system/matterbridge
```
### Show Matterbridge status
```bash
sudo launchctl print system/matterbridge
```
### Show Matterbridge status (only essentials)
```bash
sudo launchctl print system/matterbridge | grep -E "pid|state"
```
### Enable Matterbridge to start automatically on boot
```bash
sudo launchctl enable system/matterbridge
```
### Disable Matterbridge from starting automatically on boot
```bash
sudo launchctl disable system/matterbridge
```
### View the log of Matterbridge in real time (this will show the log with colors)
```bash
sudo tail -n 1000 -f /var/log/matterbridge.log /var/log/matterbridge.err
```
### Optional: automatically rotate logs (every 5 days or at 100 MB, keep 5 compressed backups)
```bash
sudo tee /etc/newsyslog.d/matterbridge.conf <<'EOF'
/var/log/matterbridge.log root:wheel 640 5 102400 5 ZC
/var/log/matterbridge.err root:wheel 640 5 102400 5 ZC
EOF
sudo newsyslog -v
```
### Optional: remove the password prompt for sudo
```bash
sudo EDITOR=nano visudo
```
Add this line at the end of the file (replace USER with your macOS username):
```text
USER ALL=(ALL) NOPASSWD: ALL
```
Save and validate syntax:
```bash
sudo visudo -c
```
### Optional: ask for password only each 60 minutes
```bash
sudo EDITOR=nano visudo
```
Add (or edit) this line anywhere in the file:
```text
Defaults timestamp_timeout = 60
```
Save and validate syntax:
```bash
sudo visudo -c
```