{"id":2642,"date":"2019-10-01T21:42:25","date_gmt":"2019-10-01T20:42:25","guid":{"rendered":"http:\/\/www.dpscomputing.com\/blog\/?p=2642"},"modified":"2021-03-01T21:36:41","modified_gmt":"2021-03-01T21:36:41","slug":"mysqli_connect-hy000-2002-no-connection-could-be-made-because-the-target-machine-actively-refused-it","status":"publish","type":"post","link":"https:\/\/www.dpscomputing.com\/blog\/2019\/10\/01\/mysqli_connect-hy000-2002-no-connection-could-be-made-because-the-target-machine-actively-refused-it\/","title":{"rendered":"mysqli_connect(): (HY000\/2002): No connection could be made because the target machine actively refused it"},"content":{"rendered":"\n<p>So you&#8217;ve come to do a bit of development and you fire up XAMMP or AMPPS only to find&#8230; boom!  You&#8217;re hit with an error.  <\/p>\n\n\n\n<p>Is it a dev error?  Did I leave something broke last time?  These are all possibilities &#8211; however, when you see this error:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysqli_connect(): (HY000\/2002): No connection could be made because the target machine actively refused it<\/code><\/pre>\n\n\n\n<p>The likely cause is usually quite simple to fix and a quick configuration change (and back) should help you recover.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How To Fix<\/h2>\n\n\n\n<p>We&#8217;ll walk through the process in AMPPS, the steps are similar in other clients.  <\/p>\n\n\n\n<p>If you haven&#8217;t already, start the AMPPS application server.  <\/p>\n\n\n\n<p>Then open the main AMPPS window (if it&#8217;s not already on screen, double click the colourful AMPPS icon in your toolbar):<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"254\" height=\"282\" data-attachment-id=\"2643\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2019\/10\/01\/mysqli_connect-hy000-2002-no-connection-could-be-made-because-the-target-machine-actively-refused-it\/image-5-4\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-5.png\" data-orig-size=\"254,282\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-5\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-5.png\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-5.png\" tabindex=\"0\" role=\"button\" src=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-5.png\" alt=\"\" class=\"wp-image-2643\" srcset=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-5.png 254w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-5-135x150.png 135w\" sizes=\"auto, (max-width: 254px) 100vw, 254px\" \/><\/figure><\/div>\n\n\n\n<p>Click the &#8216;cog&#8217; icon next to MySQL:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"240\" height=\"44\" data-attachment-id=\"2644\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2019\/10\/01\/mysqli_connect-hy000-2002-no-connection-could-be-made-because-the-target-machine-actively-refused-it\/image-6-3\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-6.png\" data-orig-size=\"240,44\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-6\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-6.png\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-6.png\" tabindex=\"0\" role=\"button\" src=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-6.png\" alt=\"\" class=\"wp-image-2644\" srcset=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-6.png 240w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-6-150x28.png 150w\" sizes=\"auto, (max-width: 240px) 100vw, 240px\" \/><\/figure><\/div>\n\n\n\n<p>Then click the settings icon (the spanner and screwdriver):<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"251\" height=\"50\" data-attachment-id=\"2645\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2019\/10\/01\/mysqli_connect-hy000-2002-no-connection-could-be-made-because-the-target-machine-actively-refused-it\/image-7-3\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-7.png\" data-orig-size=\"251,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-7\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-7.png\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-7.png\" tabindex=\"0\" role=\"button\" src=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-7.png\" alt=\"\" class=\"wp-image-2645\" srcset=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-7.png 251w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-7-150x30.png 150w\" sizes=\"auto, (max-width: 251px) 100vw, 251px\" \/><\/figure><\/div>\n\n\n\n<p>This should open the my.ini file for your local SQL server.  From here, navigate to the &#8216;Server Section&#8217; and search for the innodb_force_recovery option:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"226\" data-attachment-id=\"2646\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2019\/10\/01\/mysqli_connect-hy000-2002-no-connection-could-be-made-because-the-target-machine-actively-refused-it\/image-8-3\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-8.png\" data-orig-size=\"601,226\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-8\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-8-300x113.png\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-8.png\" tabindex=\"0\" role=\"button\" src=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-8.png\" alt=\"\" class=\"wp-image-2646\" srcset=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-8.png 601w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-8-150x56.png 150w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-8-300x113.png 300w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n\n<p>This is and should usually be 0.  Set this to one.  Save the configuration file and head back to the AMPPS control panel.  From there, you should notice a message saying your configuration has been successfully updated:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"167\" height=\"22\" data-attachment-id=\"2647\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2019\/10\/01\/mysqli_connect-hy000-2002-no-connection-could-be-made-because-the-target-machine-actively-refused-it\/image-9-3\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-9.png\" data-orig-size=\"167,22\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-9\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-9.png\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-9.png\" tabindex=\"0\" role=\"button\" src=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-9.png\" alt=\"\" class=\"wp-image-2647\" srcset=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-9.png 167w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-9-150x20.png 150w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-9-160x22.png 160w\" sizes=\"auto, (max-width: 167px) 100vw, 167px\" \/><\/figure><\/div>\n\n\n\n<p>Now we need to restart the MySQL server by clicking the restart button.  CAUTION!  The restart button and the reset button icons are easily mixed up &#8211; hover over the icon if your unsure to display the tooltip to ensure you get the right one!<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"251\" height=\"57\" data-attachment-id=\"2648\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2019\/10\/01\/mysqli_connect-hy000-2002-no-connection-could-be-made-because-the-target-machine-actively-refused-it\/image-10-3\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-10.png\" data-orig-size=\"251,57\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-10\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-10.png\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-10.png\" tabindex=\"0\" role=\"button\" src=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-10.png\" alt=\"\" class=\"wp-image-2648\" srcset=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-10.png 251w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-10-150x34.png 150w\" sizes=\"auto, (max-width: 251px) 100vw, 251px\" \/><\/figure><\/div>\n\n\n\n<p>Once you&#8217;ve pressed this, you should see a message that the server has been successfully restarted:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"104\" height=\"22\" data-attachment-id=\"2649\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2019\/10\/01\/mysqli_connect-hy000-2002-no-connection-could-be-made-because-the-target-machine-actively-refused-it\/image-11-3\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-11.png\" data-orig-size=\"104,22\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-11\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-11.png\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-11.png\" tabindex=\"0\" role=\"button\" src=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-11.png\" alt=\"\" class=\"wp-image-2649\"\/><\/figure><\/div>\n\n\n\n<p>Now if you try to visit your web page hosted on localhost it should now load correctly.  <\/p>\n\n\n\n<p>We shouldn&#8217;t leave recovery mode on after things are back up and running  &#8211; some things won&#8217;t work correctly or behave strangely.  Head back to the configuration file, set the value of innodb_force_recovery back to 0 and restart the MySQL server again.  <\/p>\n\n\n\n<p>Hey presto &#8211; your localhost development server is back up and running!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So you&#8217;ve come to do a bit of development and you fire up XAMMP or AMPPS only to find&#8230; boom! You&#8217;re hit with an error. Is it a dev error? Did I leave something&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2644,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"mysqli_connect(): (HY000\/2002): No connection could be made because the target machine actively refused it #development #websites #MySQLError #localhost","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[29],"tags":[2458,2454,2455,2460,2453,2456,2457,2459],"class_list":["post-2642","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-hy000-2002","tag-localhost-mysql","tag-localhost-mysql-error","tag-localhost-website-wont-connect","tag-mysql-error","tag-mysqli_connect-error","tag-mysqli_connect","tag-no-connection-could-be-made-because-the-target-machine-actively-refused-it"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2019\/10\/image-6.png","jetpack_shortlink":"https:\/\/wp.me\/p3nsfA-GC","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/2642","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/comments?post=2642"}],"version-history":[{"count":2,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/2642\/revisions"}],"predecessor-version":[{"id":3034,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/2642\/revisions\/3034"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/media\/2644"}],"wp:attachment":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/media?parent=2642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/categories?post=2642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/tags?post=2642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}