# Unable to create client for temporal managed cloud

**URL:** <https://community.temporal.io/t/unable-to-create-client-for-temporal-managed-cloud/6177>\
**Category:** Community Support\
**Tags:** go-sdk, temporal-cloud\
**Created:** [October 10, 2022, 11:16pm UTC](https://community.temporal.io/t/unable-to-create-client-for-temporal-managed-cloud/6177 "2022-10-10T23:16:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harrison\_Smith](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/harrison_smith/32/2851_2.png) [@Harrison\_Smith](https://community.temporal.io/u/Harrison_Smith)\
**Post date:** [October 10, 2022, 11:16pm UTC](https://community.temporal.io/t/unable-to-create-client-for-temporal-managed-cloud/6177/1 "2022-10-10T23:16:49Z")

</div>

Howdy folks,  
I am trying to connect to our new temporal managed cloud instance and i’m facing all types of errors when I try different things like:

```auto
	temporalClient, err := client.Dial(client.Options{
		Namespace: "<namespace>",
		HostPort: "<namespace>.tmprl.cloud:7233",
		ConnectionOptions: client.ConnectionOptions{
			TLS: &tls.Config{
				Certificates: []tls.Certificate{deps.Certificate()},
				RootCAs: deps.RootCA(),
				MinVersion: tls.VersionTLS12,
			},
		},
	})

```

One example of an error i’m getting:

```auto
failed reaching server: last connection error: connection closed before server preface received

```

Another error i’m getting is when i change the hostport to web..tmprl.cloud:7233:

```auto
failed reaching server: last connection error: connection error: desc = "transport: authentication handshake failed: tls: first record does not look like a TLS handshake"

```

What is interesting, after setting up an mTLS cluster in our localstack, the initialising client works, but when we try to connect to our managed cloud instance it doesnt work. Any help is appreciated.

Cheers folks!

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [October 11, 2022, 1:51am UTC](https://community.temporal.io/t/unable-to-create-client-for-temporal-managed-cloud/6177/2 "2022-10-11T01:51:03Z")

</div>

> connection closed before server preface received

One of the reasons this error can happen is when using expired client certs.

As for the code, can you give below a shot and see if you run into any issues?

```auto
cert, err := tls.LoadX509KeyPair("mypem.pem", "mykey.key")
if err != nil {
	// ...
}

c, err := client.Dial(client.Options{
	HostPort: "<namespace>.tmprl.cloud:7233",
	Namespace: "<namespace>",
	ConnectionOptions: client.ConnectionOptions{
		TLS: &tls.Config{
			Certificates: []tls.Certificate{cert},
			ServerName: "<namespace>.tmprl.cloud",
		},
	},
})

```

---

<div class="post-metadata">

**Author:** ![Harrison\_Smith](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/harrison_smith/32/2851_2.png) [@Harrison\_Smith](https://community.temporal.io/u/Harrison_Smith)\
**Post date:** [October 11, 2022, 1:57am UTC](https://community.temporal.io/t/unable-to-create-client-for-temporal-managed-cloud/6177/3 "2022-10-11T01:57:05Z")

</div>

Het Tihomir, thanks for your reply. When I try this change, the new error changes too:

```auto
failed reaching server: last connection error: connection error: desc = "transport: authentication handshake failed: tls: first record does not look like a TLS handshake"

```

I’ve asked someone from our infrastructure team to confirm if the certificate is still valid, however I am fairly sure it is and will update if it isnt.

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [October 11, 2022, 2:05am UTC](https://community.temporal.io/t/unable-to-create-client-for-temporal-managed-cloud/6177/4 "2022-10-11T02:05:19Z")

</div>

Ok, thanks. Also it would help if you opened a Zendesk ticket for this. With ticket we could ask team to check for any possible issues on server config end as well.
