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

# Connection Issues

> Troubleshoot Ollama and AI provider connection problems

Connection issues with Ollama or other AI providers can occur for several reasons. This guide covers common connection problems and their solutions.

## Common Error Messages

You may encounter the following error messages when experiencing connection issues:

### Direct Connection Error

![Direct connection error](https://image.pageassist.xyz/Screenshot%202024-05-13%20001742.png)

This error indicates that Page Assist cannot reach your Ollama server.

### 403 Error When Sending a Message

![403 error when sending a message](https://image.pageassist.xyz/Screenshot%202024-05-13%20001940.png)

This error is caused by CORS (Cross-Origin Resource Sharing) restrictions. Since Page Assist is a browser extension, it needs to communicate with the server through the browser, but browsers restrict communication between different origins.

## Solutions

<AccordionGroup>
  <Accordion title="Solution 1: Configure Custom Origin URL" icon="gear">
    Page Assist automatically rewrites request headers to work with Ollama, but this only works for `http://127.0.0.1:*` and `http://localhost:*` URLs.

    <Steps>
      <Step title="Open Page Assist Settings">
        Click on the Page Assist icon in your browser toolbar and click on the **Settings** icon.
      </Step>

      <Step title="Navigate to Ollama Settings">
        Click on the **Ollama Settings** tab.
      </Step>

      <Step title="Expand Advanced Configuration">
        Find and expand the **Advanced Ollama URL Configuration** option.

        ![Advanced Ollama URL Configuration](https://image.pageassist.xyz/Screenshot%202024-05-13%20003123.png)
      </Step>

      <Step title="Enable Custom Origin URL">
        Toggle on the **Enable or Disable Custom Origin URL** option.

        ![Enable or Disable Custom Origin URL](https://image.pageassist.xyz/Screenshot%202024-05-13%20003225.png)

        <Tip>
          If Ollama is running on a different port, change the URL in the **Custom Origin URL** field. Otherwise, leave it as the default value.
        </Tip>
      </Step>

      <Step title="Save Changes">
        Click the **Save** button to apply your changes.
      </Step>
    </Steps>

    This should resolve the connection issue, and you'll be able to use Ollama without any problems on Page Assist.
  </Accordion>

  <Accordion title="Solution 2: Set OLLAMA_ORIGINS Environment Variable" icon="terminal">
    You can set `OLLAMA_ORIGINS=*` to allow connections from any origin. Follow the instructions for your operating system:

    <Tabs>
      <Tab title="Windows">
        <Steps>
          <Step title="Open Environment Variables">
            1. Open the Start menu and search for "Environment Variables"
            2. Click "Edit the system environment variables"
          </Step>

          <Step title="Add New Variable">
            1. Click the "Environment Variables" button
            2. Under "System Variables", click "New"
          </Step>

          <Step title="Configure Variable">
            * Set Variable name: `OLLAMA_ORIGINS`
            * Set Variable value: `*`
            * Click OK to save
          </Step>

          <Step title="Restart Ollama">
            Restart the Ollama service for changes to take effect.
          </Step>
        </Steps>
      </Tab>

      <Tab title="macOS">
        <Steps>
          <Step title="Open Terminal">
            Launch the Terminal application.
          </Step>

          <Step title="Set Environment Variable">
            Run the following command:

            ```bash theme={null}
            launchctl setenv OLLAMA_ORIGINS "*"
            ```
          </Step>

          <Step title="Restart Ollama">
            Restart the Ollama service for changes to take effect.
          </Step>
        </Steps>
      </Tab>

      <Tab title="Linux">
        <Steps>
          <Step title="Open Terminal">
            Launch your terminal application.
          </Step>

          <Step title="Set Environment Variable">
            Run the following command:

            ```bash theme={null}
            export OLLAMA_ORIGINS="*"
            ```

            <Note>
              This sets the variable for the current session only. To make it permanent, add this line to your `~/.bashrc` or `~/.zshrc` file.
            </Note>
          </Step>

          <Step title="Restart Ollama">
            Restart the Ollama service for changes to take effect.
          </Step>
        </Steps>

        **For systemd users:**

        If you're using systemd to manage Ollama, you can add the environment variable to your service file:

        ```bash theme={null}
        [Unit]
        Description=Ollama Service
        After=network-online.target

        [Service]
        Environment="OLLAMA_HOST=192.168.4.67:11434"
        Environment="OLLAMA_ORIGINS=*"
        ExecStart=/usr/local/bin/ollama serve
        User=ollama
        Group=ollama
        Restart=always
        RestartSec=3

        [Install]
        WantedBy=default.target
        ```

        After editing the service file, reload systemd and restart Ollama:

        ```bash theme={null}
        sudo systemctl daemon-reload
        sudo systemctl restart ollama
        ```
      </Tab>

      <Tab title="Docker">
        If you're running Ollama in Docker, add the environment variable to your docker run command or docker-compose.yml:

        **Docker run:**

        ```bash theme={null}
        docker run -d \
          -e OLLAMA_ORIGINS="*" \
          -p 11434:11434 \
          ollama/ollama
        ```

        **Docker Compose:**

        ```yaml theme={null}
        version: '3'
        services:
          ollama:
            image: ollama/ollama
            ports:
              - "11434:11434"
            environment:
              - OLLAMA_ORIGINS=*
        ```
      </Tab>
    </Tabs>
  </Accordion>
</AccordionGroup>

## Additional Troubleshooting

<AccordionGroup>
  <Accordion title="Ollama is not running" icon="circle-exclamation">
    Make sure Ollama is actually running on your system:

    1. Check if Ollama is running by visiting `http://localhost:11434` in your browser
    2. You should see "Ollama is running" if it's active
    3. If not, start Ollama using the command: `ollama serve`
  </Accordion>

  <Accordion title="Wrong port configuration" icon="network-wired">
    Verify that Page Assist is using the correct port:

    1. Check which port Ollama is running on (default is 11434)
    2. In Page Assist settings, go to **Ollama Settings**
    3. Verify the Ollama URL matches your configuration (e.g., `http://localhost:11434`)
  </Accordion>

  <Accordion title="Firewall blocking connection" icon="shield">
    Your firewall may be blocking the connection:

    1. Check your firewall settings
    2. Allow connections to port 11434 (or your custom port)
    3. For Windows, add an exception in Windows Defender Firewall
    4. For Linux, use `ufw` or `iptables` to allow the port
  </Accordion>

  <Accordion title="Using a remote Ollama server" icon="server">
    If you're connecting to a remote Ollama instance:

    1. Make sure the server is accessible from your network
    2. Use the full URL including the IP address: `http://192.168.1.100:11434`
    3. Ensure OLLAMA\_HOST is set on the server to allow external connections:
       ```bash theme={null}
       OLLAMA_HOST=0.0.0.0:11434
       ```
    4. Configure OLLAMA\_ORIGINS on the server as described in Solution 2
  </Accordion>
</AccordionGroup>

## Still Having Issues?

If you've tried all the solutions above and still face connection issues, please [open an issue on GitHub](https://github.com/n4ze3m/page-assist/issues/new) with:

* Your operating system and version
* Your browser and version
* The exact error message you're seeing
* Your Ollama version (`ollama --version`)
* Your Page Assist settings configuration

We'll be happy to help you resolve the issue.
