# Bug: Can't access space by gradio\_client since gradio 4.x

**URL:** <https://discuss.huggingface.co/t/bug-cant-access-space-by-gradio-client-since-gradio-4-x/63222>\
**Category:** 🤗Hub\
**Created:** [November 23, 2023, 3:19am UTC](https://discuss.huggingface.co/t/bug-cant-access-space-by-gradio-client-since-gradio-4-x/63222 "2023-11-23T03:19:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dabgy](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@dabgy](https://discuss.huggingface.co/u/dabgy)\
**Post date:** [November 23, 2023, 3:19am UTC](https://discuss.huggingface.co/t/bug-cant-access-space-by-gradio-client-since-gradio-4-x/63222/1 "2023-11-23T03:19:15Z")

</div>

I’ve tested on

- Gradio 3.x on local machine (success)
- Gradio 4.x on local machine (success)
- Gradio 3.x on HuggingFace public space (success)
- Gradio 3.x on HuggingFace private space with proper token space (success)
- Gradio 4.x on HuggingFace public space (success)
- **Gradio 4.x** on HuggingFace **private space with proper token** ( 💔 bug!)

with gradio\_client (python)

Server side `app.py`:

```python
import gradio as gr

def greet(name):
    return "Hello " + name + "!!"

iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch( show_error=True, server_name='0.0.0.0' , share=True)

```

Client side code:

```python
#!/usr/bin/python3.11

from gradio_client import Client
import time

def call():
    client=Client('myusername/test', \
                  hf_token='hf_xxxxxxxxxxxxxxxxxxxxxxxxx' \
              )
    client.view_api() # success

    r = client.predict('john', fn_index=0, api_name="/predict") # fail
    return r

r = call()
print(r)

```

I got result:

```auto
Loaded as API: https://myusername-test.hf.space ✔

Client.predict() Usage Info
---------------------------
Named API endpoints: 1

- predict(name, api_name="/predict") -> output
Parameters:
- [Textbox] name: str
Returns:
- [Textbox] output: str

Traceback (most recent call last):
File "/tmp/gclient.py", line 16, in <module>
r = call("sdf")
^^^^^^^^^^^
File "/tmp/gclient.py", line 13, in call
r = client.predict('sss', fn_index=0, api_name="/predict")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/john/.local/lib/python3.11/site-packages/gradio_client/client.py", line 305, in predict
return self.submit(*args, api_name=api_name, fn_index=fn_index).result()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/john/.local/lib/python3.11/site-packages/gradio_client/client.py", line 1456, in result
return super().result(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib64/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/john/.local/lib/python3.11/site-packages/gradio_client/client.py", line 869, in _inner
predictions = _predict(*data)
^^^^^^^^^^^^^^^
File "/home/john/.local/lib/python3.11/site-packages/gradio_client/client.py", line 894, in _predict
result = utils.synchronize_async(self._sse_fn, data, hash_data, helper)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/john/.local/lib/python3.11/site-packages/gradio_client/utils.py", line 664, in synchronize_async
return fsspec.asyn.sync(fsspec.asyn.get_loop(), func, *args, **kwargs) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/fsspec/asyn.py", line 103, in sync
raise return_result
File "/usr/lib/python3.11/site-packages/fsspec/asyn.py", line 56, in _runner
result[0] = await coro
^^^^^^^^^^
File "/home/john/.local/lib/python3.11/site-packages/gradio_client/client.py", line 1075, in _sse_fn
return await utils.get_pred_from_sse(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/john/.local/lib/python3.11/site-packages/gradio_client/utils.py", line 341, in get_pred_from_sse
return task.result()
^^^^^^^^^^^^^
File "/home/john/.local/lib/python3.11/site-packages/gradio_client/utils.py", line 410, in stream_sse
raise ValueError(f"Unexpected message: {line}")
ValueError: Unexpected message: <!DOCTYPE html>
<html class="">
<head>
<meta property="og:type" content="website"/>
<title>Hugging Face – The AI community building the future.</title>
.........
.........
.........
</head>

<body> <main> <img src="https://huggingface.co/front/assets/huggingface_logo.svg" alt="" /> <div>
<h1>404</h1>
<p>Sorry, we can’t find the page you are looking for.</p>
</div> </main> </body> </html>

```

The `view_api()` successfully got API usage,  
which means I got the access to my private space.  
But `predict()` can’t work.

---

<div class="post-metadata">

**Author:** ![abidlabs](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/abidlabs/32/21878_2.png) [@abidlabs](https://discuss.huggingface.co/u/abidlabs)\
**Post date:** [November 24, 2023, 6:45pm UTC](https://discuss.huggingface.co/t/bug-cant-access-space-by-gradio-client-since-gradio-4-x/63222/2 "2023-11-24T18:45:08Z")

</div>

Hi @dabgy sorry this is a bug that we’ll fix soon. Please follow [Gradio APIs breaks calling private endpoints on HF · Issue #6430 · gradio-app/gradio · GitHub](https://github.com/gradio-app/gradio/issues/6430) for updates.
