Met the 503 code status error when run ollama to connect localhost for chat on M3 apple silicon #90

Closed
opened 2026-02-15 16:27:56 -05:00 by yindo · 4 comments
Owner

Originally created by @smile836 on GitHub (May 20, 2024).

Description

I met the 503 code status error, when I run ollama to connect localhost for chat on apple silicon.
Local machine: M3 Max MacBook Pro, Ollama, llama3, python3.11

The code:

import ollama

response = ollama.chat(model='llama3', messages=[
  {
    'role': 'user',
    'content': 'Why is the sky blue?',
  },
])
print(response['message']['content'])```


the error:

Traceback (most recent call last):
  File "/Users/jing/Desktop/hj/lesson1/test4.py", line 10, in <module>
    chat_completion = client.chat.completions.create(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_utils/_utils.py", line 277, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/resources/chat/completions.py", line 579, in create
    return self._post(
           ^^^^^^^^^^^
  File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1240, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 921, in request
    return self._request(
           ^^^^^^^^^^^^^^
  File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1005, in _request
    return self._retry_request(
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1053, in _retry_request
    return self._request(
           ^^^^^^^^^^^^^^
  File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1005, in _request
    return self._retry_request(
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1053, in _retry_request
    return self._request(
           ^^^^^^^^^^^^^^
  File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1020, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.InternalServerError: Error code: 503```

Root casuse analysis

I try curl to test API is OK

curl -X POST http://localhost:11434/v1/chat/completions -H "Content-Type: application/json" -d '{
 "model": "llama3",
 "messages": [
   {"role": "user", "content": "Say this is a test"}
 ]
}'

check server is OK

$lsof -i :11434

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ollama  29656 jing    3u  IPv4 0x5cf26da56a7362d3      0t0  TCP localhost:11434 (LISTEN)

add timeout, but also get 503

Attempt 1 failed with error: Error code: 503
Attempt 2 failed with error: Error code: 503
Attempt 3 failed with error: Error code: 503
Attempt 4 failed with error: Error code: 503
Attempt 5 failed with error: Error code: 503
An error occurred: Error code: 503

I would like to know the root cause of this error. I suspect it's because the apple silicon is not supported, is that correct?

Originally created by @smile836 on GitHub (May 20, 2024). # Description I met the 503 code status error, when I run ollama to connect localhost for chat on apple silicon. Local machine: M3 Max MacBook Pro, Ollama, llama3, python3.11 The code: ``` import ollama response = ollama.chat(model='llama3', messages=[ { 'role': 'user', 'content': 'Why is the sky blue?', }, ]) print(response['message']['content'])``` ``` the error: ``` Traceback (most recent call last): File "/Users/jing/Desktop/hj/lesson1/test4.py", line 10, in <module> chat_completion = client.chat.completions.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_utils/_utils.py", line 277, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/resources/chat/completions.py", line 579, in create return self._post( ^^^^^^^^^^^ File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1240, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 921, in request return self._request( ^^^^^^^^^^^^^^ File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1005, in _request return self._retry_request( ^^^^^^^^^^^^^^^^^^^^ File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1053, in _retry_request return self._request( ^^^^^^^^^^^^^^ File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1005, in _request return self._retry_request( ^^^^^^^^^^^^^^^^^^^^ File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1053, in _retry_request return self._request( ^^^^^^^^^^^^^^ File "/Users/jing/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1020, in _request raise self._make_status_error_from_response(err.response) from None openai.InternalServerError: Error code: 503``` ``` # Root casuse analysis I try curl to test API is OK ``` curl -X POST http://localhost:11434/v1/chat/completions -H "Content-Type: application/json" -d '{ "model": "llama3", "messages": [ {"role": "user", "content": "Say this is a test"} ] }' ``` check server is OK ``` $lsof -i :11434 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ollama 29656 jing 3u IPv4 0x5cf26da56a7362d3 0t0 TCP localhost:11434 (LISTEN) ``` add timeout, but also get 503 ``` Attempt 1 failed with error: Error code: 503 Attempt 2 failed with error: Error code: 503 Attempt 3 failed with error: Error code: 503 Attempt 4 failed with error: Error code: 503 Attempt 5 failed with error: Error code: 503 An error occurred: Error code: 503 ``` I would like to know the root cause of this error. I suspect it's because the apple silicon is not supported, is that correct?
yindo closed this issue 2026-02-15 16:27:56 -05:00
Author
Owner

@wxjttxs commented on GitHub (May 28, 2024):

I met the same error. how could do to solve this problem?

@wxjttxs commented on GitHub (May 28, 2024): I met the same error. how could do to solve this problem?
Author
Owner

@smile836 commented on GitHub (May 29, 2024):

The issue was solved. When I close my VPN, it run OK. You can check if your VPN is off.

@smile836 commented on GitHub (May 29, 2024): The issue was solved. When I close my VPN, it run OK. You can check if your VPN is off.
Author
Owner

@yili001 commented on GitHub (Sep 27, 2025):

The issue was solved. When I close my VPN, it run OK. You can check if your VPN is off.

I am using a global proxy, this working for me too.

@yili001 commented on GitHub (Sep 27, 2025): > The issue was solved. When I close my VPN, it run OK. You can check if your VPN is off. I am using a global proxy, this working for me too.
Author
Owner

@PatrickCao2015 commented on GitHub (Oct 24, 2025):

The issue was solved. When I close my VPN, it run OK. You can check if your VPN is off.

it works for me

@PatrickCao2015 commented on GitHub (Oct 24, 2025): > The issue was solved. When I close my VPN, it run OK. You can check if your VPN is off. it works for me
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#90