Skip to content

Instantly share code, notes, and snippets.

@chrisdiana
Last active March 19, 2026 12:44
Show Gist options
  • Select an option

  • Save chrisdiana/e2e471f4451f5fa16c3b9ef28037c57a to your computer and use it in GitHub Desktop.

Select an option

Save chrisdiana/e2e471f4451f5fa16c3b9ef28037c57a to your computer and use it in GitHub Desktop.
Getting mosh server running on macOS Catalina

Running into this error message when trying to run a mosh server on macOS Catalina? The steps below should solve the problem which is most likely either a $PATH and/or firewall issues.

command not found: mosh-server
Connection to X.X.X.X closed.
/usr/local/bin/mosh: Did not find mosh server startup message. (Have you installed mosh on your server?)

1. Install Mosh

$ brew install mosh

2. Update path to include mosh-server

zsh

$ echo "export PATH=$PATH:/usr/local/bin" >> ~/.zshenv

bash

$ echo "export PATH=$PATH:/usr/local/bin" >> ~/.bashrc

3. Update the firewall

# Turn the firewall off
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off

# Enable the firewall rules (make sure you are using your actual path)
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /usr/local/bin/mosh-server

# Unblock the app
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp /usr/local/bin/mosh-server

# Turn the firewall back on
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

4. Now try connecting using the mosh client

$ mosh [email protected]
@dberkholz
Copy link
Copy Markdown

Just got mosh-server running on a Mac via SSH using this little snippet. Thanks!

@Boggnogg
Copy link
Copy Markdown

Just an addition if the above does not work (had the same issue while trying to connect from iPad to iMac (Ventura)):

If you installed mosh via brew, the binaries are usually located in '/usr/local/Cellar/mosh/...' and only links created in '/usr/local/bin'. For the macOS Firewall to allow connections, you have to give permissions to the binary and not the symlink. So just add '/usr/local/Cellar/mosh/.../mosh-server' for incoming connections. - Worked for me.

@mipmip
Copy link
Copy Markdown

mipmip commented Aug 31, 2023

@Boggnogg this last part made it working. Thanks!

@penso
Copy link
Copy Markdown

penso commented Sep 17, 2023

Just an addition if the above does not work (had the same issue while trying to connect from iPad to iMac (Ventura)):

If you installed mosh via brew, the binaries are usually located in '/usr/local/Cellar/mosh/...' and only links created in '/usr/local/bin'. For the macOS Firewall to allow connections, you have to give permissions to the binary and not the symlink. So just add '/usr/local/Cellar/mosh/.../mosh-server' for incoming connections. - Worked for me.

That fixed it here too. Thanks!

@ojtibi
Copy link
Copy Markdown

ojtibi commented Jun 12, 2024

Just an addition if the above does not work (had the same issue while trying to connect from iPad to iMac (Ventura)):

If you installed mosh via brew, the binaries are usually located in '/usr/local/Cellar/mosh/...' and only links created in '/usr/local/bin'. For the macOS Firewall to allow connections, you have to give permissions to the binary and not the symlink. So just add '/usr/local/Cellar/mosh/.../mosh-server' for incoming connections. - Worked for me.

Hello, would this mean that every time I upgrade MOSH through Homebrew I need to run socketfilterfw?

@grrowl
Copy link
Copy Markdown

grrowl commented Aug 9, 2025

you can run this to handle wherever you installed mosh (brew, whatever)

# Turn the firewall off
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off

# Enable the firewall rules (make sure you are using your actual path)
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add $(which mosh-server)

# Unblock the app
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp $(which mosh-server)

# Turn the firewall back on
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

@1d10t
Copy link
Copy Markdown

1d10t commented Mar 19, 2026

brew install mosh
MOSH_BIN=$(which mosh-server)
MOSH_BINDIR=$(dirname $MOSH_BIN)
echo "export PATH=$PATH:$MOSH_BINDIR" >> ~/.zshenv
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add $MOSH_BIN
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp $MOSH_BIN
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment