Unable to get Go sample working


I’m trying Neon for the first time, and am successful with connecting via psql , DBeaver and even Python w/psycopg2. I’ve moved on to connecting with a Go application, starting with your code sample in the Dashboard. When I use the sample verbatim get:

2022/07/08 13:03:55 dial tcp: lookup winter-bread-979269.cloud.neon.tech:5432: no such host

This looks like a code sample error? Moving the port to its own parameter or removing it helps. I then get:

2022/07/08 13:04:32 pq: SNI is missing. EITHER please upgrade the postgres client library OR pass the project name as a parameter: '...&options=project%3D<project-name>...'

I added options=project=takeout to my DSN which got me to:

2022/07/08 13:12:52 pq: Internal error

I followed a similar flow using https://github.com/JackC/pgx and got to a similar spot:

ERROR: Internal error (SQLSTATE CXX000)

Very strange that only the Go drivers are choking. Any ideas?


Hi Jim!

Can you try setting sslmode=verify-full in connection options? That should help with both pq and pgx.

Hi Stas,

Thanks, that was enough to get me going. When using psycopg2 I had sslmode=require (per another error message) and it was sufficient there, so it threw me off the scent of sslmode. I guess the underlying TLS requirements are different in Go.

So all together this is the diff between the dashboard-provided code sample vs what I needed to connect:

connStr := "user=kalafut password=<% password %> dbname=main host=winter-bread-123456.cloud.neon.tech:5432"

connStr := "user=kalafut password=<% password %> dbname=main host=winter-bread-123456.cloud.neon.tech sslmode=verify-full"

Hopefully that smooths the Go onboarding a bit.


1 Like

I had this exact error message on a db client that was using an old version of libpq. My problem was that I did not know the project name. The project name is actually what’s in the host: PROJECTNAME.cloud.neon.tech. Passing that into the options solved my issue.

1 Like

Note related to Go at all, but I also got tripped up by this.

FWIW, if anyone of the neon staff reads this, the docs at Connecting with old clients — Neon Docs could use an update.

Where it says “project name” it should probably read “project ID” in reference to the settings page:

Thank you for bringing this up! Now rereading the error message, I see that it refers to the project name but does not explain what the project name is. I’ll rename project name to project id in doc and in the proxy error message. Any suggestion on how to improve the error message text to be more clear?