# Tailscale & VPN Setup

> Connect to your Audiobookshelf server through Tailscale or other VPNs

Source: https://soundleafapp.com/docs/tailscale-vpn-setup/

---

Running Audiobookshelf on your home network and want to access it remotely via Tailscale? Here's how to get SoundLeaf connected.

## Quick Setup

The key is using the right URL format:

```
http://HOSTNAME
```

Where `HOSTNAME` is your Tailscale MagicDNS name (e.g., `audiobookshelf`, `nas`, `server`).

**Examples that work:**
- `http://audiobookshelf`
- `http://my-nas`
- `http://192.168.1.100:13378` (local IP when on home network)

**Common mistakes:**
- Using `https://` when your server doesn't have SSL
- Including the Tailscale domain suffix (usually not needed)
- Forgetting the `http://` prefix entirely

## Why HTTP Instead of HTTPS?

Most home Audiobookshelf setups don't have SSL certificates configured. Tailscale's connection is already encrypted, so HTTP over Tailscale is secure.

If you don't specify a protocol, SoundLeaf tries HTTPS first and then HTTP. That works, but the HTTPS attempt has to fail first, and a Tailscale host commonly drops the connection rather than refusing it, which is the slow kind of failure.

**Always explicitly include `http://` for non-SSL servers.**

## Tailscale Sidecar Setup

If you're running Audiobookshelf in Docker with a Tailscale sidecar container (no port exposure), your URL is simply the container's MagicDNS name:

```
http://audiobookshelf
```

No port number needed since the sidecar handles routing.

## Split Tunnel Considerations

If you have Tailscale configured with split tunneling (only routing certain traffic through the VPN):

1. Make sure your Audiobookshelf server's IP/hostname is included in the routed subnets
2. Or use the Tailscale IP directly (found in your Tailscale admin console)

## Local vs Remote Access

Want different URLs for home vs away? SoundLeaf holds both and switches on its own: a local address for your home Wi-Fi and a list of addresses for everywhere else. See [Home and Away Server Addresses](https://soundleafapp.com/docs/server-addresses/).

Tailscale users can usually skip the local address entirely and put the Tailscale address in the external list, since Tailscale routes directly when both machines are on the same network.

## Troubleshooting

### "Connection failed" error

1. Verify Tailscale is connected on your iPhone (check the Tailscale app)
2. Try the Tailscale IP instead of hostname: `http://100.x.x.x:13378`
3. Confirm you can reach the server in Safari first

### Works in browser but not SoundLeaf

Make sure you're including `http://` in the URL. Browsers auto-detect the protocol; SoundLeaf defaults to HTTPS if not specified.

### Intermittent disconnections

- Check your Tailscale key hasn't expired
- Ensure "Allow incoming connections" is enabled on the server's Tailscale client
- Try disabling battery optimization for Tailscale on your server if applicable
