Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Connecting a Self-Hosted Ollama Server to WordPress (and Why localhost Won’t Work)

Description and use

Configuring a local Ollama server for WordPress: change the listening address, restrict access, and test connectivity.

Problem

WordPress plugins that use Ollama fail to connect when the Ollama server is on a different machine because the plugin uses localhost, which refers to the web server itself.

Outcome

After configuring Ollama to listen on a reachable address, securing the port, and verifying connectivity from both the shell and PHP, the WordPress plugin can successfully connect to the local LLM and generate content.

Workflow

  • Install Ollama and pull a model on the server that will host it.
  • Determine whether Ollama and WordPress share the same machine; if not, configure Ollama to listen on a network address reachable by WordPress (e.g., set OLLAMA_HOST via systemd override).
  • Secure the Ollama port by limiting inbound traffic to the WordPress server using a firewall (e.g., ufw).
  • Test connectivity from the WordPress server’s shell using curl to the Ollama API endpoints.
  • Test connectivity from PHP inside WordPress using wp_remote_post via WP-CLI to ensure the WordPress HTTP API can reach Ollama.
  • Adjust timeouts or model size if requests time out, considering cold starts and hardware limits.
  • Configure the WordPress plugin with the Ollama server URL and model name, then test the connection within the plugin settings.
  • Use the plugin’s workflow to generate content, review, and apply it to posts.

Evidence

When a WordPress plugin calls http://localhost:11434, the request is made by PHP on the web server. "localhost" means the web server itself, not your laptop.

Source

Ollama’s API has no built-in authentication. Anyone who can reach port 11434 can run prompts on your hardware.

Source

curl http://10.0.0.5:11434/api/tags # Does generation work? curl http://10.0.0.5:11434/api/generate -d '{"model": "llama3.2", "prompt": "Write a page title for a bakery in Leeds.", "stream": false}'

Source

  • Record date: 2026-10-21T15:41:20.759Z