Write:broken pipe is usually an indication that an idle connection has been closed by the server.
There is an API in database/sql package for this reason. See https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime Assuming you are using MySQL, MariaDB, you can read current timeout settings using command show variables like '%timeout%'; And the result will look lise this: +-----------------------------+----------+ | Variable_name | Value | +-----------------------------+----------+ | connect_timeout | 5 | | deadlock_timeout_long | 50000000 | | deadlock_timeout_short | 10000 | | delayed_insert_timeout | 300 | | innodb_flush_log_at_timeout | 1 | | innodb_lock_wait_timeout | 50 | | innodb_rollback_on_timeout | OFF | | interactive_timeout | 28800 | | lock_wait_timeout | 31536000 | | net_read_timeout | 30 | | net_write_timeout | 60 | | slave_net_timeout | 3600 | | thread_pool_idle_timeout | 60 | | wait_timeout | 28800 | +-----------------------------+----------+ In this case, the interactive_timeout value is basically idle connection timeout. After 28800 seconds of inactivity, the server will automatically close the connection. To prevent further errors set connection lifetime to value less than configured. eg. db.SetConnMaxLifetime(time.Second * 14400) On Saturday, December 23, 2017 at 2:23:21 PM UTC+1, jobs jobs wrote: > > how to fix it? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.