struggling with cpanel issues after migration, need help

Author
James Brown Author
|
5 days ago Asked
|
15 Views
|
2 Replies
0
hey everyone, i'm pretty new to this whole website migration thing and just finished moving a small client's site to a new host, trying to do it all myself for the first time. it's been a bit of a struggle, to be honest.

i'm facing some persistent cPanel issues, mostly around file permissions and database connection errors, even after double-checking and updating the wp-config.php file like a hundred times. it's really slowing down the site launch and my client is starting to get a little antsy. i keep seeing stuff like this in the logs:

[04-Jan-2024 10:35:01 UTC] PHP Warning: mysqli_connect(): (HY000/2002): Connection refused in /home/user/public_html/wp-includes/wp-db.php on line 1653
[04-Jan-2024 10:35:01 UTC] PHP Fatal error: Error establishing a database connection in /home/user/public_html/wp-includes/wp-db.php on line 1653
[04-Jan-2024 10:35:01 UTC] WordPress database error: Error establishing a database connection

i'm wondering if this is just normal growing pains for manual migrations, or if i'm totally missing something fundamental about proper Website Maintenance & cPanel Management Services practices. maybe i should have just gone for some managed services from the start instead of DIYing it. any advice on common pitfalls or best practices for dealing with these post-migration headaches would be super helpful. anyone faced this before?

2 Answers

0
MD Alamgir Hossain Nahid
Answered 5 days ago

Regarding your post-migration cPanel issues, specifically the database connection errors, let's address the common culprits. First, a quick note: ensure you're capitalizing your "I"s in future posts; it helps with readability. Now, back to the technical details.

The Connection refused error is almost always a database configuration problem or an issue with the MySQL service itself. While you've checked wp-config.php, there are specific aspects that need rigorous verification. Hereโ€™s a structured approach to troubleshoot this:

  • Database Host Verification: Double-check the DB_HOST value in your wp-config.php. While localhost is common, some hosts require a specific IP address or hostname for the database server, especially in clustered environments. Confirm this with your new host's documentation or support.
  • Database User Privileges: Ensure the database user specified in wp-config.php has full privileges (SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER) on the specific database you're trying to connect to. You can verify and grant these permissions via cPanel's "MySQL Databases" interface.
  • MySQL Service Status: Confirm that the MySQL server is actively running on your new host. This is a fundamental server-side check that usually requires access to cPanel's "Service Status" or, if you have SSH access, by running a command like systemctl status mysql or service mysql status.
  • Firewall Configuration: A server-level firewall (e.g., CSF/LFD) might be blocking connections to MySQL (port 3306). If your DB_HOST is not localhost, ensure the firewall allows outbound connections from your web server to the database server on the relevant port.
  • File Permissions: While less directly related to Connection refused, incorrect file permissions can cause other issues. For WordPress, directories should generally be 755 and files 644. For wp-config.php, a more secure permission like 640 or 600 is often recommended, but 644 typically works without issues. Ensure the web server user has read access to this file.
  • Check cPanel Error Logs: Beyond the PHP warnings, look for specific MySQL error logs or general server error logs in cPanel or via SSH, which might provide more granular details about why the connection is being refused. This is crucial for effective database troubleshooting.

These steps cover the most frequent causes of database connection errors after a migration and are part of standard web hosting configuration practices. Address each point systematically to identify the root cause.

0
James Brown
Answered 5 days ago

Yeah, the DB_HOST tip and checking user privileges totally solved the connection refused issue, huge relief! But now I'm getting a 500 error every time I try to upload an image in WordPress...

Your Answer

You must Log In to post an answer and earn reputation.