If you’re a WordPress user with, at least, a few months of shared hosting experience, you might notice error messages like “Connection timed out“. That’s a problem that causes lots of other issues, especially if you have a membership website.
That error message will display when you reach all your server resources and memory usage. But, you will not get a regular notification that really the server can’t handle any extra executions.
The problem itself, can’t give the exact locations where you need to fix things. But, the general idea is that the server is not able to receive or execute any other request from web browsers, or, from your plugins or themes.
If you’re using CloudFlare for example, the error is the same as the above, but with code 522 that means the server is not responding for a long time.
Like any other problem on the web, there are solutions and you can start applying them one by one if you’re not sure which method will work for you.
If you’ve tried to increase the memory limit, that will solve the problem only, if you’re hosting your WordPress blog or website with a powerful hosting company. In the other cases, where you’re using a shared hosting, the memory limit increase will not solve the connection errors, in general. That’s simply because the resources are shared, and if it works now, it will return again later and so on.
So, first, if you really want to forget these errors completely, you need to use an optimized WordPress hosting service with powerful resources. I recommend the premium WP Engine, as they’re the leaders in the premium and managed WordPress hosting industry.
Also, if you use a CDN, you’ll speed up your site naturally and also, you will save lots of resources and the execution time will be faster. I only recommend MaxCDN as the real and the most secure platform.
Now, let’s fix the problem in the shared hosting environments, especially.
Increasing the maximum execution time
We will try to increase the execution time on your server, it’s the first thing to verify, as the error talks about the time in the connection. That means a probable issue with the maximum execution time. The first thing that you need is the “php.ini” file in your server.
Please remember, WordPress will not add this file to your blog. It’s the server configuration and the hosting company is the only one who can manage that file, and let their customers edit it or not. If you find the file, but you can’t edit it, then, you need to contact your hosting customer support. Then, and ask them to increase your maximum memory limit.
If you’re able to find the php.ini file and you can edit its content, then, add the following code and save it.
max_execution_time = 60 ;
The second option is to edit the “htaccess” file. If you can’t find that file, you can create it by yourself, all you have to do is to create a new file named “.htaccess”. Then, update your permalinks to let WordPress regenerate its engine code automatically.
If you have already an “htaccess” file like the majority of sites, then, you can add the following code to increase the maximum execution time that’s 30 seconds by default.
php_value max_execution_time 60
Of course, you need to save the file after making the changes. This will fix the problem if the server can handle more requests, but the limited execution time is what’s causing the problem.
Deactivate your plugins
When you have lots of plugins and, especially, the ones with lots of PHP request to your server, it becomes critical, sometimes to execute and respond to all these thousands of requests. So, make sure to disable all your plugins at once, from your WordPress dashboard. That will let you verify if you have things to correct with your plugins or not.
Reactivate your plugins one by one, until you find the exact one that has the problem. Then, delete it, or search for an alternative tool. If you’re using plugins that you need once a week, for example, then, deactivating them will be better.
If you can’t access your admin area and you can’t activate or disable plugins, then, you can disable them from your cPanel, by renaming each plugin. For example, add “off” to the end of all your plugin names. That will disconnect them from WordPress, and they will no longer work until you remove that “off” at the end.
Find your plugins folder in “wp-content/plugins”, then rename the plugin “Akismet”, for example, to “AkismetOff” and repeat that for all the others. Then, test your site when you reactivate every single plugin by deleting the “off”.
Increase the PHP allocated memory
The maximum memory allocated on shared hosting servers make things limited. So, no more PHP executions if you reach your limit. In some cases, you get connection timed out error, and not a memory size error message.
To increase your maximum PHP limit, you need to add the following code to your “wp-confing.php” file.
define( 'WP_MEMORY_LIMIT', '64M' );
This will work only if you’re allowed to increase the memory limit. Some hosting companies will close the doors to their users to allocate more memory. In that case, you should contact them and ask to allow your site more memory.
Verify your theme
In other cases, the theme can be the problem if it sends lots of requests, and it’s not well coded with the minimum optimization. It’s a simple thing that you switch to another theme, or simply, to use one of the default WordPress themes then, verify if things work properly.
Also, you can scan your theme for malware if you’re not sure about its source. That’s another thing that you should avoid, free themes cause lots of problems and can destroy websites.
Check your server file compression
This is another rare case that can fix the problem if you have a big number of requests to your server. You can compress the HTML and text files, that will reduce the number of requests from the web browser to the server.
These are the things to verify when you have a timed out error messages in general, and in WordPress especially. WordPress needs lots of resources and that’s why the optimized WordPress hosting becomes popular and a need in the last years. The huge number of PHP executions and requests will never work with a classic hosting environment.