How to run multiple tmux servers with different sockets?

Quick Answer

Use the -L flag to create separate tmux servers with different socket names: tmux -L work new-session creates a "work" server independent from your default tmux server.

tmux -L work new-session -s main

Detailed Explanation

Multiple tmux servers allow you to completely isolate different environments or projects. Each server maintains its own sessions, windows, and panes independently, using different socket files for communication.

Creating and Using Different Servers

# Create separate servers
tmux -L work new-session -s main
tmux -L personal new-session -s home

# List sessions on specific servers
tmux -L work list-sessions
tmux -L personal list-sessions

# Attach to specific server
tmux -L work attach-session -t main

Common Use Cases

  • Work/Personal separation: Keep professional and personal projects isolated
  • Client projects: Each client gets their own tmux server environment
  • Testing configurations: Experiment without affecting your main setup
  • Different tmux configs: Each server can use different configuration files

Pro Tip

Create shell aliases for quick access to different tmux servers:

# Add to your shell config (~/.zshrc, ~/.bashrc)
alias work='tmux -L work'
alias personal='tmux -L personal'

# Usage
work new-session -s project1
personal attach-session -t home

Socket File Locations

Each server creates its socket in /tmp/tmux-{uid}/{socket-name}. You can also specify custom socket paths with -S /path/to/socket.