# 'cluster\_url' must be one of: \[\<class 'str'\>\], but got \<class 'NoneType'\>

**URL:** <https://forum.weaviate.io/t/cluster-url-must-be-one-of-class-str-but-got-class-nonetype/1958>\
**Category:** General\
**Created:** [April 9, 2024, 2:16am UTC](https://forum.weaviate.io/t/cluster-url-must-be-one-of-class-str-but-got-class-nonetype/1958 "2024-04-09T02:16:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bo\_sun](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/bo_sun/32/1276_2.png) [@bo\_sun](https://forum.weaviate.io/u/bo_sun)\
**Post date:** [April 9, 2024, 2:16am UTC](https://forum.weaviate.io/t/cluster-url-must-be-one-of-class-str-but-got-class-nonetype/1958/1 "2024-04-09T02:16:38Z")

</div>

‘cluster\_url’ must be one of: [\<class ‘str’\>], but got \<class ‘NoneType’\>

what`s going on here? I got my cluster\_url , but cannot use it

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [April 9, 2024, 12:39pm UTC](https://forum.weaviate.io/t/cluster-url-must-be-one-of-class-str-but-got-class-nonetype/1958/2 "2024-04-09T12:39:55Z")

</div>

hi @bo_sun ! Welcome to our community 🤗

Can you share some more code?

My bet is that if your are using a variable to define the cluster\_url, it’s not working, as the client seems to be complaining that you passed a None value as the cluster\_url, instead of a string.

Can you try replacing this variable with the actual value of the url, or print this cluster\_url before passing it to the client?

Thanks!

---

<div class="post-metadata">

**Author:** ![VIVEK](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/vivek/32/1660_2.png) [@VIVEK](https://forum.weaviate.io/u/VIVEK)\
**Post date:** [June 3, 2024, 5:58am UTC](https://forum.weaviate.io/t/cluster-url-must-be-one-of-class-str-but-got-class-nonetype/1958/3 "2024-06-03T05:58:00Z")

</div>

hi @DudaNogueira print(type(APIKEY))

```auto
client = weaviate.connect_to_wcs(
    cluster_url=URL,
    auth_credentials=weaviate.auth.AuthApiKey(APIKEY)
    # headers={
    # "X-OpenAI-Api-Key": os.environ["sk-xxx-xxxxx"] # Replace with your inference API key
    # }
)

```

I used legitimate apikeys and url but it’s still showing the error

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/weaviate/original/2X/9/93b614a833ea116ccacb4872fbcbcb0c4ae8a02d.png)  
weaviate.exceptions.WeaviateInvalidInputError: Invalid input provided: Argument ‘cluster\_url’ must be one of: [\<class ‘str’\>], but got \<class ‘NoneType’\>.

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [June 7, 2024, 6:45pm UTC](https://forum.weaviate.io/t/cluster-url-must-be-one-of-class-str-but-got-class-nonetype/1958/4 "2024-06-07T18:45:21Z")

</div>

hi @VIVEK !! Welcome to our community 🤗

Check your `URL` variable.

it is probably set to `None` instead of the value you want.

---

<div class="post-metadata">

**Author:** ![sebawita](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/sebawita/32/5_2.png) [@sebawita](https://forum.weaviate.io/u/sebawita)\
**Post date:** [June 10, 2024, 8:01am UTC](https://forum.weaviate.io/t/cluster-url-must-be-one-of-class-str-but-got-class-nonetype/1958/5 "2024-06-10T08:01:41Z")

</div>

Hi @VIVEK,  
You accidentally shared your API key, which I removed now, but you should probably cancel it and generate a new one.

> [@VIVEK](#):
>
> ```python
> # "X-OpenAI-Api-Key": os.environ["sk-xxx-xxxxx"] # Replace with your inference API key
> 
> ```

The reason you are getting `None` is because you are passing the key into the `os.environ()` function call. This function is used to get the value of the provided environment variable. For example, you can add `OPENAI_APIKEY =bla-bla-bla` to your env variables, then when you call

```python
os.environ("OPENAI_APIKEY")

```

You will get back “bla-bla-bla”

To solve this you have two options:

## Option 1 - Add OPENAI\_APIKEY env var

Add `OPENAI_APIKEY` to your environment variables, then connect to the client.

> Note, the latest Weaviate client changed `connect_to_wcs()` to `connect_to_weaviate_cloud()`

```python
client = weaviate.connect_to_weaviate_cloud(
    cluster_url=URL,
    auth_credentials=weaviate.auth.AuthApiKey(APIKEY)
    headers={
        “X-OpenAI-Api-Key”: os.environ["OPENAI_APIKEY"]
    }
)

```

## Option 2 - provide the API key directly

> Note, this approach is not safe if you plan to share your code, as you will expose your keys.

```python
client = weaviate.connect_to_weaviate_cloud(
    cluster_url=URL,
    auth_credentials=weaviate.auth.AuthApiKey(APIKEY)
    headers={
        “X-OpenAI-Api-Key”: "your-api-key-goes-here"
    }
)

```
