<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQLSTATE[HY000] [2002] Archives - Artificial Intelligence</title>
	<atom:link href="https://www.aiuniverse.xyz/tag/sqlstatehy000-2002/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.aiuniverse.xyz/tag/sqlstatehy000-2002/</link>
	<description>Exploring the universe of Intelligence</description>
	<lastBuildDate>Tue, 25 Feb 2025 13:35:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>SQLSTATE[HY000] [2002] Connection refused</title>
		<link>https://www.aiuniverse.xyz/sqlstatehy000-2002-connection-refused/</link>
					<comments>https://www.aiuniverse.xyz/sqlstatehy000-2002-connection-refused/#respond</comments>
		
		<dc:creator><![CDATA[Maruti Kr.]]></dc:creator>
		<pubDate>Tue, 25 Feb 2025 13:34:48 +0000</pubDate>
				<category><![CDATA[laravel]]></category>
		<category><![CDATA[Clear Laravel cache]]></category>
		<category><![CDATA[DB_SOCKET configuration]]></category>
		<category><![CDATA[Fix MySQL connection error]]></category>
		<category><![CDATA[Laravel .env file configuration]]></category>
		<category><![CDATA[Laravel database connection]]></category>
		<category><![CDATA[Laravel database connection error solution]]></category>
		<category><![CDATA[Laravel DB_SOCKET fix]]></category>
		<category><![CDATA[Laravel optimize commands]]></category>
		<category><![CDATA[Laravel route cache clear]]></category>
		<category><![CDATA[MySQL Unix socket path]]></category>
		<category><![CDATA[Optimize Laravel application]]></category>
		<category><![CDATA[PHP MySQL connection refused]]></category>
		<category><![CDATA[SQLSTATE[HY000] [2002]]]></category>
		<category><![CDATA[Troubleshooting PHP MySQL connection]]></category>
		<category><![CDATA[XAMPP MySQL socket issue]]></category>
		<guid isPermaLink="false">https://www.aiuniverse.xyz/?p=20845</guid>

					<description><![CDATA[<p>Step-by-Step Solution: 5. Save the .env File: 6. Clear Route, Cache, and Optimize the Application: Conclusion: By adding the DB_SOCKET line to your .env file, you can easily fix the Connection refused error caused by socket connection issues in local PHP environments like XAMPP. This simple change can save you a lot of troubleshooting time <a class="read-more-link" href="https://www.aiuniverse.xyz/sqlstatehy000-2002-connection-refused/">Read More</a></p>
<p>The post <a href="https://www.aiuniverse.xyz/sqlstatehy000-2002-connection-refused/">SQLSTATE[HY000] [2002] Connection refused</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="511" src="https://www.aiuniverse.xyz/wp-content/uploads/2025/02/image-1024x511.png" alt="" class="wp-image-20846" srcset="https://www.aiuniverse.xyz/wp-content/uploads/2025/02/image-1024x511.png 1024w, https://www.aiuniverse.xyz/wp-content/uploads/2025/02/image-300x150.png 300w, https://www.aiuniverse.xyz/wp-content/uploads/2025/02/image-768x383.png 768w, https://www.aiuniverse.xyz/wp-content/uploads/2025/02/image.png 1293w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>Step-by-Step Solution:</strong></p>



<ol class="wp-block-list">
<li><strong>Locate the .env File:</strong>
<ul class="wp-block-list">
<li>The <code>.env</code> file is located in the root directory of your PHP or Laravel application. This file contains key-value pairs for environment-specific configurations.</li>
</ul>
</li>



<li><strong>Edit the .env File:</strong>
<ul class="wp-block-list">
<li>Open the <code>.env</code> file in a text editor, such as VSCode or Sublime Text.</li>
</ul>
</li>



<li><strong>Add the DB_SOCKET Configuration:</strong>
<ul class="wp-block-list">
<li>Inside the <code>.env</code> file, add the following line to specify the MySQL socket location: <code>DB_SOCKET=/opt/lampp/var/mysql/mysql.sock</code></li>



<li>This line tells your application where to find the MySQL socket file, which resolves the connection refusal when using a local development environment like XAMPP.</li>
</ul>
</li>



<li><strong>Verify Other Database Configuration:</strong>
<ul class="wp-block-list">
<li>Ensure that your database connection settings are correctly set. Below is an example of a full database configuration block in the <code>.env</code> file: </li>
</ul>
</li>
</ol>



<pre class="wp-block-code"><code>DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_user
DB_PASSWORD=your_database_password
DB_SOCKET=/opt/lampp/var/mysql/mysql.sock</code></pre>



<p>5. <strong>Save the .env File:</strong></p>



<ul class="wp-block-list">
<li>After adding the socket configuration, save the <code>.env</code> file.</li>
</ul>



<p>6. <strong> Clear Route, Cache, and Optimize the Application:</strong></p>



<ul class="wp-block-list">
<li>Once you&#8217;ve updated the <code>.env</code> file, it&#8217;s essential to clear and optimize the Laravel application&#8217;s cache, routes, and configuration. This will ensure your changes are reflected and improve the application&#8217;s performance. Run the following commands from your terminal:</li>
</ul>



<pre class="wp-block-code"><code>php artisan config:cache        # Clear and cache the configuration files
php artisan route:cache         # Clear and cache the route files
php artisan cache:clear         # Clear the application's cache
php artisan optimize            # Optimize the application's performance</code></pre>



<ol class="wp-block-list"></ol>



<p><strong>Conclusion:</strong> By adding the <code>DB_SOCKET</code> line to your <code>.env</code> file, you can easily fix the <code>Connection refused</code> error caused by socket connection issues in local PHP environments like XAMPP. This simple change can save you a lot of troubleshooting time and get your PHP application connecting to MySQL without errors.</p>
<p>The post <a href="https://www.aiuniverse.xyz/sqlstatehy000-2002-connection-refused/">SQLSTATE[HY000] [2002] Connection refused</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.aiuniverse.xyz/sqlstatehy000-2002-connection-refused/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
