ANTIGRAVITY LABJP
Articles/Antigravity Basics
Antigravity Basics/2026-04-09Beginner

Antigravity Local LLM (Ollama) Connection Error: Complete Diagnosis and Fix Guide

Can't connect Antigravity to your local LLM (Ollama)? This diagnostic guide walks through every possible cause — ports, firewalls, model configs, environment variables — with step-by-step fixes.

Antigravity321Ollama15local LLM14connection errortroubleshooting105

Working with Antigravity and want to run a local LLM through Ollama? It's powerful, but when connection issues pop up — "can't connect," "model not found," "no API response" — it can be frustrating. This guide helps you pinpoint exactly what's wrong and fix it, step by step.

Recognizing Your Error Pattern

Connection errors might look the same on the surface, but they usually stem from different root causes. Let's identify which pattern matches what you're experiencing:

Connection Timeout

  • Message example: "Connection timeout," "No response from localhost:11434"
  • Likely cause: Ollama isn't running, wrong port, or firewall blocking

Empty Model List

  • Message example: "Available models: []," "No models loaded"
  • Likely cause: Ollama is running but hasn't pulled (downloaded) any models yet

API Response Error

  • Message example: "500 Internal Server Error," "Invalid request format"
  • Likely cause: Configuration format mismatch or request structure problem

Authentication / Permission Issues

  • Message example: "Permission denied," "Authentication failed"
  • Likely cause: User permissions or missing environment variables

Keep these patterns in mind as we work through the diagnostic steps below.

Step 1: Verify Ollama Is Running

The first and most crucial check: Is Ollama actually running? Skip this, and all subsequent diagnostics are wasted effort.

On macOS/Linux

Open a terminal and run:

ollama list

If Ollama is running properly, you'll see your installed models:

NAME                    ID              SIZE      MODIFIED
llama2:latest           c75d82f30b65    3.8 GB    2 minutes ago
mistral:latest          8f3797de41b5    4.1 GB    1 hour ago
neural-chat:latest      282e9238f2d6    4.1 GB    3 hours ago

If the output is blank (no models), Ollama is running but you haven't downloaded models yet. We'll handle that in Step 4.

If You Get an Error

Error: couldn't connect to running Ollama instance

Ollama isn't running. Launch the Ollama app from your menu, or start the server manually:

ollama serve

Then open another terminal tab and retry ollama list.

On Windows

After installing Ollama for Windows, launch it from your Start menu. Then in Command Prompt or PowerShell:

ollama list

If PowerShell complains about execution policy:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Then retry.

Step 2: Check Ports and Firewall Access

Once Ollama is confirmed running, let's verify that Antigravity can actually reach it. The key things here are port number and firewall permissions.

Ollama's Default Port

Ollama runs on port 11434 by default. Your Antigravity connection URL should be http://localhost:11434 or http://127.0.0.1:11434. If you've set a custom port via the OLLAMA_HOST environment variable:

echo $OLLAMA_HOST

Test the Port Connection

Use curl to see if the API is responding:

curl http://localhost:11434/api/tags

A successful response looks like this (JSON of your installed models):

{"models":[{"name":"llama2:latest","modified_at":"2026-04-01T10:00:00.000000000Z","size":3825930240},{"name":"mistral:latest","modified_at":"2026-04-02T15:30:00.000000000Z","size":4294967296}]}

If Connection Is Refused

curl: (7) Failed to connect to localhost port 11434: Connection refused

This means Ollama either isn't listening or crashed. Go back to Step 1 and verify it's actually running.

macOS Firewall Check

If you have macOS firewall enabled, it might block Antigravity's localhost requests:

  1. Go to System SettingsSecurity & PrivacyFirewall
  2. Click Firewall Options
  3. Either uncheck "Block all incoming connections" temporarily, or add Ollama to the exceptions list

Then retry the curl command above.

Windows Firewall

  1. Open Windows Defender FirewallAllow an app through firewall
  2. Click Change settings → add Ollama to the allowlist

Or from an admin Command Prompt:

netstat -ano | findstr :11434

If you see a LISTENING entry, port 11434 is open.

Step 3: Verify Antigravity's LLM Configuration

Ollama is running and the port is open. Now let's confirm Antigravity's settings actually point to Ollama correctly.

Environment Variables

Create a .env.local file in your Antigravity project root:

NEXT_PUBLIC_LLM_PROVIDER=ollama
NEXT_PUBLIC_OLLAMA_BASE_URL=http://localhost:11434
NEXT_PUBLIC_OLLAMA_MODEL=llama2

Note: Use http:// (not https://) for localhost. HTTPS will block localhost connections.

Configuration File

Some projects use antigravity.config.ts:

export const llmConfig = {
  provider: "ollama",
  baseUrl: "http://localhost:11434",
  model: "llama2",
  temperature: 0.7,
};

Reflect Configuration Changes

After updating your env or config file, restart the dev server:

# Stop the server (Ctrl+C), then:
npm run dev
# or
yarn dev

Check your browser's Network tab (F12 → Network) and look for Ollama requests. They should return status 200.

Step 4: Verify Model Name and Quantization Compatibility

If Ollama is running and the port is open but you still can't connect, the issue is likely a model name mismatch.

List Your Installed Models

ollama list

Example output:

NAME                    ID              SIZE      MODIFIED
llama2:latest           c75d82f30b65    3.8 GB    1 hour ago
mistral:7b-instruct     a33e5e2d6b48    3.8 GB    2 hours ago
neural-chat:7b-q4       ab1c2d3e4f5g    2.1 GB    1 day ago

The NAME column must match exactly what you've configured in Antigravity.

Common Model Name Mistakes

  • Set Antigravity to mistral but you installed mistral:7b-instruct
  • Used uppercase in the model name (Llama2 instead of llama2)
  • Omitted the tag (wrote mistral instead of mistral:latest)

Update your Antigravity config to match an installed model exactly. If you don't have a model you want, pull it:

ollama pull llama2:latest

Quantization Variants

Ollama distributes quantized (compressed) versions of models for efficiency. Examples:

  • llama2:7b — full size
  • llama2:7b-q4_0 — quantized to ~4GB (slight quality loss)
  • llama2:7b-q5_K_M — higher-fidelity quantization (~5GB)

Make sure your Antigravity configuration and what's installed match. If you configure mistral:7b but installed mistral:7b-q4_0, expect errors.

Your options:

  1. Install the full-size model: ollama pull mistral:7b
  2. Update your Antigravity config to the installed variant: mistral:7b-q4_0

If you're low on memory, quantized versions are the way to go.

Deep Dive: Logs and CORS

Still stuck? Let's look at detailed logs and common advanced issues.

Check Ollama's Log

# macOS
cat ~/.ollama/logs/server.log
 
# Linux
journalctl -u ollama -n 50

Look for error or failed:

cat ~/.ollama/logs/server.log | grep -i error

Browser Console Errors

Press F12 → Console tab. Look for messages like:

// Uncaught Error: Failed to fetch from http://localhost:11434
// CORS error: No 'Access-Control-Allow-Origin' header is present

If You See CORS Errors

When Antigravity is a web app, the browser's CORS security might block cross-port requests to Ollama. Fix it:

  1. Enable CORS on Ollama:
export OLLAMA_ORIGINS=*
ollama serve

Or more restrictively:

export OLLAMA_ORIGINS=http://localhost:3000
ollama serve
  1. Use a backend proxy: Route Ollama requests through your Antigravity backend API instead of directly from the browser.

Restart Ollama Cleanly

pkill ollama
sleep 2
ollama serve

Or just restart the app from your menu.

Cache Clearing and Full Reinstall

Often the issue is stale cache or Node modules. Do this nuclear option:

# In your Antigravity project directory
npm cache clean --force
rm -rf node_modules
rm -rf .next
npm install
npm run dev

On Windows:

npm cache clean --force
rmdir /s node_modules
rmdir /s .next
npm install
npm run dev

Looking back

When Antigravity can't reach your local Ollama, work through these steps:

  • Step 1: Run ollama list to confirm Ollama is running
  • Step 2: Use curl to test http://localhost:11434/api/tags; check firewall settings
  • Step 3: Verify Antigravity's .env.local or config file has the correct base URL and uses http:// (not https://)
  • Step 4: Confirm your configured model name matches exactly what ollama list shows
  • Advanced: Check logs, verify CORS settings, clear cache, and do a full reinstall if needed

Follow these methodically and you'll find your issue. Happy local LLM building!

Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

Antigravity2026-04-14
Antigravity Local LLM Not Connecting: Complete Troubleshooting Guide
Can't get Antigravity to connect to your local LLM? This guide covers all four failure patterns — Ollama not running, LM Studio server not started, VRAM issues, and macOS firewall blocking — with diagnostic commands and step-by-step fixes.
Antigravity2026-05-02
Gemma 4 × Antigravity Complete Practical Guide — Local LLM, RAG, Ollama/LM Studio Integration
A practical, production-grade guide to running Antigravity with Gemma 4 — covering local LLM setup, RAG pipelines, Ollama/LM Studio integration, and fine-tuning. Includes troubleshooting and operational best practices.
Antigravity2026-04-23
Antigravity × Local LLM (Ollama / LM Studio / LM Link): A Production Connection Playbook
Getting Antigravity to connect to Ollama, LM Studio, or LM Link is the easy part. Running on that setup for eight hours a day, week after week, surfaces disconnects, model-swap hangs, stale sessions after lunch, and VRAM pressure from other processes. This playbook covers hardening the connection layer, picking the right backend for the task, and designing the fallback path for when local goes silent.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →