Fork me on GitHub

Ubuntu22.04下MaxKB中接入Ollama发生API URL域名不存在问题 (Ollama以DeepSeek1.5b为例)

 

实验环境: Ollama下的DeepSeek(详情请戳链接)、MaxKB(详情链接

问题原因:Ollama未关闭默认地址绑定。

解决方案:

OLLAMA_HOST=0.0.0.0 ollama serve

出现错误:

 解决方式:

This will stop the Ollama service immediately.

sudo systemctl stop ollama

 

Since Ollama is likely managed by systemd, disable it so it doesn't restart:

sudo systemctl disable ollama

 

Check if anything is still running on port 11434:

sudo lsof -i :11434

If there’s no output, the port is free.

Now, restart Ollama with remote access enabled:

OLLAMA_HOST=0.0.0.0 ollama serve

成功

 

 大功告成


 

 

 

When to Re-enable Ollama in systemd

If you want Ollama to start automatically every time you restart your computer, you can re-enable it with:

sudo systemctl enable ollama
sudo systemctl start ollama

However, this will start Ollama on localhost (127.0.0.1), not 0.0.0.0`. If you want remote access at boot, you need to edit the systemd service file.

 

How to Start Ollama with Remote Access at Boot

1️⃣ Open the Ollama systemd service file for editing:

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

2️⃣ Find the line that starts with ExecStart= and replace it with:

ExecStart=/usr/bin/env OLLAMA_HOST=0.0.0.0 ollama serve

3️⃣ Save the file (CTRL+X, then Y, then ENTER).

 

4️⃣ Reload systemd and restart Ollama:

sudo systemctl daemon-reload
sudo systemctl restart ollama

5️⃣ Enable Ollama to start automatically at boot:

sudo systemctl enable ollama

 

If You Don't Need Auto-Start

If you're fine with starting Ollama manually, just keep it disabled and run:

OLLAMA_HOST=0.0.0.0 ollama serve

 

posted @ 2025-03-14 11:49  z_s_s  阅读(242)  评论(0)    收藏  举报