How to Increase PHP Memory Limit in DirectAdmin (Fix WordPress Memory Errors)
If your WordPress site is showing any of the following errors, the PHP memory limit needs to be increased:
- "Fatal error: Allowed memory size of X bytes exhausted"
- "Fatal error: Out of memory"
- A white screen or blank page after installing a plugin or theme
- WordPress admin dashboard loading slowly or not loading at all
The PHP memory limit controls how much memory a PHP script is allowed to use. WordPress and its plugins can require more memory than the default setting allows — especially on resource-heavy sites with page builders, WooCommerce or multiple plugins running simultaneously.
What Is the Default PHP Memory Limit?
On Hostking shared hosting plans the default PHP memory limit is typically 256MB. For most standard WordPress sites this is sufficient. If you're hitting memory errors, increasing to 512MB usually resolves the issue.
Method 1: Increase via PHP Selector in DirectAdmin (Recommended)
This is the easiest method and does not require editing any files.
Step 1 — Log into DirectAdmin via my.hostking.host → your service → Login to DirectAdmin.
Step 2 — In the DirectAdmin menu, find and click PHP Selector or Select PHP Version. You can also type "PHP" in the DirectAdmin search bar to find it quickly.
Step 3 — Click the Options tab at the top of the PHP Selector page.
Step 4 — Find memory_limit in the list of PHP options.
Step 5 — Change the value to 512M (or higher if needed — the maximum available depends on your hosting plan).
Step 6 — Click Save or Apply.
Step 7 — Test your website to confirm the error is resolved.
Method 2: Increase via wp-config.php (WordPress Specific)
This method sets the memory limit from within WordPress itself and works well for WordPress-specific memory issues.
Step 1 — Log into DirectAdmin and open File Manager.
Step 2 — Navigate to your WordPress installation folder (usually public_html or a subdirectory if WordPress is installed in a subfolder).
Step 3 — Find the file called wp-config.php and click Edit.
Step 4 — Find the line that says:
/* That's all, stop editing! Happy publishing. */
Step 5 — Add the following line above that line:
define( 'WP_MEMORY_LIMIT', '512M' );
Step 6 — Click Save.
Step 7 — Refresh your website and check whether the error is resolved.
Method 3: Increase via .htaccess
If neither of the above methods works, you can try setting the memory limit via your .htaccess file.
Step 1 — In DirectAdmin File Manager, navigate to your public_html folder. Enable Show Hidden Files to see .htaccess.
Step 2 — Click Edit on the .htaccess file.
Step 3 — Add the following line:
php_value memory_limit 512M
Step 4 — Click Save and test your site.
Note: This method may not work on all server configurations. If it causes a 500 error, remove the line you added.
Method 4: Increase via php.ini
Step 1 — In DirectAdmin File Manager, navigate to your public_html folder.
Step 2 — Check if a file called php.ini already exists. If it does, click Edit. If not, create a new file called php.ini.
Step 3 — Add or update the following line:
memory_limit = 512M
Step 4 — Save the file and test your site.
Which Method Should I Use?
| Method | Difficulty | Best For |
|---|---|---|
| PHP Selector in DirectAdmin | Easiest | All sites — try this first |
| wp-config.php | Easy | WordPress sites only |
| .htaccess | Easy | If PHP Selector isn't available |
| php.ini | Easy | If other methods don't work |
Always try Method 1 first — it's the cleanest solution and applies to all scripts on your domain, not just WordPress.
How Much Memory Should I Set?
| Site Type | Recommended Memory Limit |
|---|---|
| Basic WordPress blog or brochure site | 256M (default) |
| WordPress with page builder (Elementor, Divi) | 512M |
| WooCommerce store | 512M |
| Large WooCommerce store or membership site | 756M or higher |
Do not set the memory limit higher than you need — it is a shared hosting environment and setting it excessively high will not speed your site up and may affect other processes.
Still Getting Memory Errors After Increasing the Limit?
If you've increased the memory limit and still see errors, the cause may be a specific plugin or theme using an unusually large amount of memory. Try:
- Deactivating all plugins and reactivating them one by one to identify the problem plugin
- Switching to a default WordPress theme to rule out a theme issue
- Checking if the error only appears on specific pages or actions
If the issue persists, open a support ticket at my.hostking.host and include the full error message — our team can check your server-level configuration.
Need Help?
Our support team is available every day from 7am to 10pm via live chat at hostking.host or by opening a ticket at my.hostking.host.
