> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/ZhFahim/anchor/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting to Server

> Configure your Anchor mobile app to connect to your self-hosted server

Anchor is a self-hosted application. To use the mobile app, you need to connect it to your running Anchor server instance.

## First Launch Setup

When you first open the Anchor mobile app, you'll be greeted with the server configuration screen.

<Steps>
  <Step title="Enter Server URL">
    The app will prompt you for your **Server URL**. This is the address where your Anchor server is running.

    Enter your server URL in one of these formats:

    * `https://anchor.yourdomain.com` (production deployment)
    * `http://your-server-ip:3000` (local network)
    * `http://10.0.2.2:3000` (Android emulator connecting to localhost)
    * `http://localhost:3000` (iOS simulator)

    <Warning>
      The URL must start with `http://` or `https://`. Don't include a trailing slash.
    </Warning>

    Example valid URLs:

    ```
    https://notes.example.com
    http://192.168.1.100:3000
    http://10.0.2.2:3000
    ```
  </Step>

  <Step title="Test Connection">
    Before connecting, tap the **Test** button to verify your server is reachable.

    The app will:

    1. Connect to your server's health endpoint (`/api/health`)
    2. Verify it's a valid Anchor server
    3. Display the server version if successful

    <Note>
      If the test fails, double-check your URL and ensure your server is running and accessible from your device.
    </Note>
  </Step>

  <Step title="Connect">
    Once the test succeeds, tap **Connect** to save your server configuration.

    The app will navigate to the login screen where you can authenticate with your credentials.
  </Step>
</Steps>

## Server URL Requirements

Your server URL must meet these requirements:

### Production Deployments

For production use with HTTPS:

```
https://anchor.yourdomain.com
```

* Must use HTTPS for security
* Requires a valid SSL certificate
* Accessible from the public internet
* No port number needed (defaults to 443)

### Local Network Access

For accessing a server on your local network:

```
http://192.168.1.100:3000
```

* Find your server's local IP address
* Include the port number (default: 3000)
* Both devices must be on the same network
* HTTP is acceptable for local development

### Android Emulator

If running the server on your development machine:

```
http://10.0.2.2:3000
```

* `10.0.2.2` is a special alias to your host machine's localhost
* This only works in Android emulators, not physical devices

### iOS Simulator

If running on iOS simulator:

```
http://localhost:3000
```

* iOS simulators can directly access the host machine's localhost
* This only works in simulators, not physical devices

## Connection Validation

The app validates your server by checking the `/api/health` endpoint:

```json theme={null}
{
  "app": "anchor",
  "version": "0.9.1"
}
```

This ensures you're connecting to a valid Anchor server and displays the server version.

## Changing Server URL

If you need to connect to a different server:

<Steps>
  <Step title="Open Settings">
    1. Tap the menu icon (≡) in the top-left
    2. Select **Settings** from the drawer
  </Step>

  <Step title="Change Server">
    1. Scroll to the **Server** section
    2. Tap **Server URL** to see your current server
    3. Tap **Change Server** to enter a new URL
  </Step>

  <Step title="Re-authenticate">
    After changing servers, you'll be logged out and need to sign in again with credentials for the new server.

    <Warning>
      Changing servers will clear local data from the previous server. Ensure your notes are synced before switching.
    </Warning>
  </Step>
</Steps>

## Troubleshooting

### Connection Timeout

**Error**: "Connection timed out. Check the URL and try again."

**Solutions**:

* Verify the server is running: `curl http://your-server:3000/api/health`
* Check your network connection
* Ensure your firewall allows connections on the server port
* For local servers, verify your device is on the same network

### Could Not Connect to Server

**Error**: "Could not connect to server. Check the URL."

**Solutions**:

* Verify the URL format is correct (starts with `http://` or `https://`)
* Check for typos in the domain or IP address
* Ensure the port number is correct
* Try accessing the URL in your device's web browser first

### Invalid Server Response

**Error**: "Invalid server response. Is this an Anchor server?"

**Solutions**:

* Ensure you're connecting to an Anchor server, not a different application
* Verify the server is fully started and healthy
* Check server logs for errors
* Ensure the `/api/health` endpoint is accessible

### SSL Certificate Errors

If using HTTPS with a self-signed certificate:

<Warning>
  Self-signed certificates are not supported in production builds for security reasons. Use a valid SSL certificate from a trusted authority (e.g., Let's Encrypt).
</Warning>

For development, use HTTP on a local network instead.

## Network Requirements

### Ports

Ensure these ports are accessible:

* **3000**: Default Anchor server port (HTTP)
* **443**: HTTPS (if using SSL)

### Firewall Configuration

If your server has a firewall:

```bash theme={null}
# Allow Anchor server port
sudo ufw allow 3000/tcp

# Or for HTTPS
sudo ufw allow 443/tcp
```

### Router Configuration

For remote access, configure port forwarding:

1. Forward external port 443 to internal port 3000 (or your server's port)
2. Use a dynamic DNS service if you don't have a static IP
3. Ensure your ISP allows incoming connections

<Note>
  For security, always use HTTPS when accessing your server over the internet.
</Note>

## Authentication

After connecting to your server, you'll need to authenticate:

### Standard Login

1. Enter your email address
2. Enter your password
3. Tap **Sign In**

### OIDC Authentication

If your server has OpenID Connect configured:

1. Tap **Sign in with SSO**
2. You'll be redirected to your identity provider
3. Complete authentication in the browser
4. You'll be redirected back to the app

### Registration

If registration is enabled on your server:

1. Tap **Create Account** on the login screen
2. Enter your name, email, and password
3. Tap **Sign Up**

<Warning>
  Registration may be disabled on some servers. Contact your server administrator if you need an account.
</Warning>

## Next Steps

Once connected and authenticated, learn about the app's offline capabilities:

<Card title="Offline Usage" icon="wifi-off" href="/mobile/offline-usage">
  Create and edit notes without an internet connection
</Card>
