How to Install Ollama and Run Ollama on Public IP

Discover the step-by-step guide on installing Ollama and configuring it to run on a public IP. Simplify your setup process with our expert tips.

Ollama Installation Steps

For Windows

1. Download Ollama - Visit the official Ollama website to download the Windows installer.

ollama download

2. Install Ollama - Run the installer and follow the on-screen instructions to complete the installation.

Install ollama
Ollama is running

3. Verify Installation - Open the Command Prompt and run the following command to confirm Ollama is installed successfully and to check the version:

ollama --version
check ollama version

For Linux

1. Download and Install Ollama - Visit the Ollama official website to find the installation command for Linux.

Ollama download for Linux

2. Install Ollama - Execute the command in the terminal to install Ollama.

Install Ollama on linux
Ollama is running

3. Verify Installation - Run the following command to verify the installation and check the Ollama version:

ollama --version
check ollama version

Configuring Ollama to Listen on Public IP

For Windows

1. Modify Environment Variables - By default, Ollama listens on 127.0.0.1:11434. To allow Ollama to listen on a public IP, follow these steps:

Press Windows + R, type sysdm.cpl, and click "OK" to open System Properties.

Ollama api curl response

2. Click the "Advanced" tab and then click "Environment Variables."

Ollama api curl response json format

3. In the "User variables" section, click "New" and create the following variable: Variable name: OLLAMA_HOST, Variable value: 0.0.0.0:11434

Ollama api curl response json format

4. Access and Test - Once the environment variable is set, you can access Ollama via the public IP. Make sure your firewall rules allow external access to this port.

Check a port is on servcice or not
Check Ollama is running or not

For Linux

1. Modify Service Configuration - By default, Ollama listens on 127.0.0.1:11434. To change this and make Ollama listen on a public IP, follow these steps:

Open the ollama.service file with a text editor:

sudo vi /etc/systemd/system/ollama.service

Add the following line under the [Service] section:

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Edit Ollama service

2. Restart the Service - After modifying the service file, reload the systemd configuration and restart Ollama:

sudo systemctl daemon-reload
sudo systemctl restart ollama

3. Access and Test - Once Ollama has been restarted, it will be accessible via the public IP address. Ensure your network and firewall settings permit external access.

Check Ollama is running or not