{"id":1442,"date":"2019-02-08T10:36:01","date_gmt":"2019-02-08T10:36:01","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2019\/02\/08\/1583503-how-to-fix-the-mysql-server-has-gone-away-error-at-hostinger\/"},"modified":"2026-08-04T06:30:18","modified_gmt":"2026-08-04T06:30:18","slug":"1583503-how-to-fix-the-mysql-server-has-gone-away-error-at-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/1583503-how-to-fix-the-mysql-server-has-gone-away-error-at-hostinger\/","title":{"rendered":"How to fix the &#8216;MySQL server has gone away&#8217; error at Hostinger"},"content":{"rendered":"<p class=\"no-margin\">The most common reason behind the &ldquo;<b>MySQL<\/b> <b>server has gone away<\/b>&rdquo; error is your <b>MySQL queries timing out<\/b>. That can happen if you use heavy or very long MySQL queries.<\/p><h2 id=\"h-why-this-error-happens\">Why this error happens<\/h2><p>Besides query timeouts, this error commonly occurs when:<\/p><ul>\n<li>You&rsquo;re importing a large SQL file via phpMyAdmin, and the import exceeds the execution time or upload size limit.<\/li>\n<li>A single query or a large piece of data (such as a BLOB or long TEXT value) exceeds the server&rsquo;s maximum allowed packet size.<\/li>\n<li>A database connection sits idle for too long before being used again, and the connection is closed in the meantime.<\/li>\n<li>The MySQL service restarts unexpectedly while a query is running.<\/li>\n<\/ul><h2 id=\"h-fix-the-mysql-server-has-gone-away-error\">Fix the &ldquo;MySQL server has gone away&rdquo; error<\/h2><ul>\n<li>For query timeouts, try adding the <strong>mysql_reconnect<\/strong> command before each query.<\/li>\n<li>For large SQL imports, split the file into smaller chunks and import them one at a time, or use SSH with the MySQL command line instead of phpMyAdmin, which isn&rsquo;t subject to the same execution time limits.<\/li>\n<li>For large individual queries or data values, try breaking the query into smaller batches instead of one large operation.<\/li>\n<\/ul><p class=\"no-margin\">If the above solution doesn&rsquo;t help, we recommend you refer for help to websites and developer community forums like <b><a class=\"intercom-content-link\" href=\"https:\/\/github.com\/\" target=\"_blank\" rel=\"noopener\">GitHub<\/a><\/b>, <b><a class=\"intercom-content-link\" href=\"https:\/\/stackoverflow.com\/\" target=\"_blank\" rel=\"noopener\">Stack Overflow<\/a><\/b>, or <b><a class=\"intercom-content-link\" href=\"https:\/\/www.fiverr.com\/\" target=\"_blank\" rel=\"noopener\">Fiverr<\/a><\/b>, where thousands of web development professionals share their knowledge &#128218;<\/p><p><strong>Other common database issues<\/strong><\/p><p>If you&rsquo;re running into a different database-related problem, see:<\/p><ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li><a href=\"https:\/\/www.hostinger.com\/support\/5534251-what-to-do-if-the-database-size-limit-has-been-reached-in-hostinger\/\">What to do if the database size limit has been reached in Hostinger<\/a><\/li>\n<li><a href=\"https:\/\/www.hostinger.com\/support\/4274567-how-to-fix-the-max_connections_per_hour-mysql-error-at-hostinger\/\">How to fix the max_connections_per_hour MySQL error<\/a><\/li>\n<li><a href=\"https:\/\/www.hostinger.com\/support\/1583555-how-to-fix-the-mysql-1064-error-at-hostinger\/\">How to fix the MySQL 1064 error<\/a><\/li>\n<li><a href=\"https:\/\/www.hostinger.com\/support\/1583511-how-to-fix-the-user-already-has-more-than-max-user-connections-error-at-hostinger\/\">How to fix the &ldquo;User already has more than max_user_connections&rdquo; error<\/a><\/li>\n<li><a href=\"https:\/\/www.hostinger.com\/support\/how-to-fix-mysql-operation-not-permitted-error\/\">How to fix the MySQL &ldquo;Operation not permitted&rdquo; error<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul><p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Solving MySQL timeout errors<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[241],"tags":[],"class_list":["post-1442","post","type-post","status-publish","format-standard","hentry","category-database-troubleshooting"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/1583503-how-to-fix-the-mysql-server-has-gone-away-error-at-hostinger\/","default":1},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/support\/1583503-como-corregir-el-error-mysql-server-has-gone-away-en-hostinger\/","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/support\/1583503-erreurs-mysql-timeout-et-server-has-gone-away-at-hostinger\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/support\/1583503-terjadi-error-mysql-timeout-dan-server-has-gone-away-di-hostinger\/","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/support\/1583503-como-corrigir-o-erro-mysql-server-has-gone-away-no-hostinger\/","default":0},{"locale":"uk-UA","link":"https:\/\/www.hostinger.com\/ua\/support\/1583503----mysql-server-has-gone-away--hostinger\/","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=1442"}],"version-history":[{"count":2,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1442\/revisions"}],"predecessor-version":[{"id":14243,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1442\/revisions\/14243"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=1442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=1442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=1442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}