Go Postgres timeout error


What's inside this article ⌄
  • Golang pgconn timeout error
  • Postgres context canceled golang
  • Fix golang Postgres timeout
  • Pgconn errtimeout context fix

Suppose you just received the following error:

*pgconn.errTimeout: timeout: context canceled

during database operation attempts in your Go app.

The first thing you need to check is your query, its performance, and timeout values. You might miss some index creations, etc.

If everything is ok with your query, and it’s working well and constantly faster than that timeout value, the reason may be another transaction. Simply put, something or somebody might start the transaction and neglect to commit (or rollback) it.

In my case, I figured out that the DB browser IntelliJ IDEA Plugin automatically started a new transaction and required a manual commit. All the time it was hanging, the Go’s pgconn driver gave timeout errors.