One place for hosting & domains

      How To Fix the WordPress Memory Exhausted Error by Increasing Your Site’s PHP Memory Limit

      As you may know, WordPress is built using PHP. This programming language is incredibly flexible, but it also has a few drawbacks. For example, if you don’t allocate enough memory for your WordPress installation, you might start running into the occasional “PHP Memory Exhausted” error.

      In a nutshell, this error means your server isn’t allocating enough resources for WordPress to execute the PHP scripts it needs to function properly. This issue can negatively affect your site’s functionality, but there are several ways you can fix and even prevent it.

      In this article, we’ll show you how to fix the memory exhausted problem by increasing your PHP memory limit. However, first, let’s talk about how to recognize this error and what it means!

      Why You’re Seeing a WordPress Memory Limit Error on Your Site

      As we mentioned earlier, the PHP memory limit error means you’re not allocating enough resources for your WordPress installation to function correctly. The problem usually presents itself with a message such as:

      The memory exhausted PHP fatal error.

      Don’t be scared by the word “fatal,” though. Your website isn’t broken, but you will need to make some changes to your WordPress installation if you want it to work properly. Specifically, you’ll want to increase your PHP memory limit.

      By “PHP memory limit,” we mean the amount of server memory that’s allocated to run PHP scripts. By default, that number should be around 64 MB or higher. In most cases, 64 MB is more than enough, however.

      Most hosting servers provide you with far more memory than that, so increasing the PHP allowed memory size shouldn’t negatively impact your website’s performance whatsoever. In fact, unless you’re using a cheap web host or you set up WordPress manually, your PHP memory limit shouldn’t be an issue at all.

      You can easily check to see what your PHP memory limit is by accessing your WordPress dashboard and navigating to Tools > Site Health > Info. Next, you can click on the Server tab and look for the PHP memory limit entry.

      A website with a high PHP memory size.

      Within the Server tab, you can also check other information such as your PHP version and the PHP time limit. The latter variable, which is in seconds, defines how long PHP scripts have to execute before they time out.

      For now, let’s focus on the PHP memory limit. As you can see, the above example has quite a high limit, which means that the website is unlikely to run into a WordPress Memory Exhausted error.

      If your site has a low memory limit (<64 MB), it’s in your best interests to increase it. There are a couple of ways you can do so.

      Take Your WordPress Website to the Next Level

      Whether you need help navigating your web hosting control panel, fixing an error, or finding the right plugin, we can help! Subscribe to our monthly digest so you never miss an article.

      How to Resolve the WordPress Memory Limit Error (2 Methods)

      As far as WordPress errors go, this one has a clear-cut cause and solution. You’re not allocating enough memory for your PHP installation, so you need to increase that number. In this section, we’ll go over two methods you can use: one manual technique and one that requires your wallet.

      1. Increase the PHP Memory Allocated to Your Website Manually

      WordPress enables you to declare your allowed memory size manually by modifying one of two files: .htaccess and wp-config.php. However, changing your WordPress installation’s .htaccess file can lead to site-wide errors since that file governs how it interacts with your server.

      Increasing your PHP memory limit through wp-config.php is, in most cases, the safest option, and it’s remarkably easy to do. All you need is a Secure File Transfer Protocol (SFTP) client such as FileZilla that you can use to connect to your website.

      Once you access your website via SFTP, open the WordPress root folder and look for the wp-config.php file within it.

      A WordPress wp-config.php file.

      Open that file using a text editor, and you should see something like this:

      Editing a wp-config.php file.

      To increase your PHP memory limit, you can simply add a single line of code anywhere after the <?php tag and before the part of the file that reads “/* That’s all, stop editing! Happy blogging. */”.

      This is the line of code to add:

      define( 'WP_MEMORY_LIMIT', 'XXXM' );

      You’ll need to replace the “XXX” variable within that line with the amount of memory you want to allocate to PHP. As we mentioned before, the absolute minimum you should settle for is 64 MB.

      However, you can also double the number to play it safe or increase it even further. For example, if you set a PHP memory limit of 256 MB, it would look like this:

      define( 'WP_MEMORY_LIMIT', ‘256M’);

      Once you’re set on a number, save the changes to wp-config.php and close the editor. Now return to your WordPress dashboard and navigate to Tools > Site Health > Info > Server to see if the changes went through.

      In some cases, declaring your PHP memory limit manually won’t work because you don’t have the necessary permissions to change that value. If you can’t adjust your WordPress memory size manually, that leaves you with one other option.

      2. Upgrade Your Website’s Hosting Plan

      Typically, if you use a decent WordPress hosting provider, you won’t need to worry about increasing your PHP memory limit. One caveat is that if you’re using shared hosting, you’ll likely face limited resources. So if you’re encountering this error, it might be time to upgrade to a better hosting plan.

      Upgrading your hosting package will usually result in an increase in available PHP memory. That means you’re much less likely to run into a WordPress memory limit error. The only limiting factor is your budget.

      If you can’t upgrade hosting plans right now, it might be worth contacting your provider’s support team and seeing if they can increase your PHP memory limit on their end. If they can’t, it might be time to switch to a better WordPress host that offers high PHP memory limits on affordable plans.

      Skip the Stress

      Avoid troubleshooting when you sign up for DreamPress. Our friendly WordPress experts are available 24/7 to help solve website problems — big or small.

      Want More WordPress Error Tips?

      Once you increase PHP memory on your WordPress website, we can help tackle other issues. We’ve put together several tutorials to help you troubleshoot every error message:

      Want more information on WordPress site management? Check out our WordPress Tutorials, a collection of guides designed to help you navigate the WordPress dashboard like an expert.

      Increasing PHP Memory Limit

      Running into a PHP fatal error can be worrying, but it’s not necessarily a cause for concern. Learning how to increase your PHP memory limit is relatively simple if you don’t mind using an SFTP client and adding a single line of code to one of WordPress’ core files.

      The alternative is to upgrade your hosting plan or opt for a better provider. Most WordPress-friendly hosting options offer high limits by default, so you’ll never run into a PHP memory exhausted error ever again.

      If you’re ready to use a web host optimized for WordPress websites, check out our DreamPress hosting packages! We offer optimized WordPress setups, so you spend less time troubleshooting errors and more time working on your website.

      Source link

      Keeping Your Sites and Users Safe Using SSL

      How to Join

      This Tech Talk is free and open to everyone. Register below to get a link to join the live stream or receive the video recording after it airs.

      Date RSVP
      February 25, 2021, 11:00 a.m.–12:00 p.m. ET

      About the Talk

      Keeping your users’ data safe is important in the digital age. People’s entire lives are now online in some way. One of the first things you can do to ensure your users’ safety is to ensure their data is transmitted to you and back securely, and for that, we use SSL. SSL is the tool responsible for HTTPS and the little safe green lock in your browser telling your user that any data they transmit to your site will be done securely.

      In this Tech Talk, I’ll go over SSL, its history and how it works, and how to secure your sites with SSL so that you can keep your users’ data safe.

      What You’ll Learn

      • What SSL is, its history, how it works, and why we need it
      • Securing your Sites with Certbot
      • Modern web servers with SSL on by default (Caddy)

      This Talk is Designed For

      Systems administrators, DevOps engineers, first-time web developers, students.


      Knowledge of how to install packages on a Linux operating system and deploy a website to a server using Nginx, Apache, or Caddy. Ubuntu is used in this talk.

      About the Presenter

      Mason Egger is currently a Developer Advocate at DigitalOcean, specializing in cloud infrastructure, distributed systems, and Python. Prior to his work at DigitalOcean, he was an SRE (Site Reliability Engineer), helping build and maintain a highly available hybrid multi-cloud PaaS. He is an avid programmer, speaker, educator, and writer/blogger. He is a maintainer of the DigitalOcean Terraform provider and contributes to random open source projects here and there. In his spare time, he enjoys reading, camping, kayaking, and exploring new places.

      To join the live Tech Talk, register here.

      Source link

      Faster WordPress Sites With Gatsby

      Talk about the latest cutting-edge web technologies, and you find some impressive names like React.js, Vue.js, Next.js, and so on. They have opened new gateways and approaches to building websites that can serve content to users quickly.

      One framework that can increase overall site speed and load times is Gatsby.js.

      Goals of a Fast Website

      A website that loads fast entails the following perks and benefits for developers:

      • Traffic and Engagement: You get more site visitors on a fast site, which translates to better ROI and user engagement.
      • Page Ranks: Fast websites earn higher browser rankings.

      Improving Site Speed With Gatsby.js and WordPress

      Gatsby.js is a free and open-source React.js-based framework that helps developers build websites and applications. It is part of a general trend toward JAMstack (JavaScript APIs Markup) sites, which aim to increase overall site speed and load times.

      But where does Gatsby fit with WordPress, one of the most widely-used CMS options available today? Despite its usability and robust community, WordPress can pose challenges to building a modern frontend, for the following reasons:

      • Updates and Changes: WordPress is regularly updated, but it still lacks parity with other rapidly-changing front-end technologies. Staying up-to-date with these technologies adds an additional burden for the developer.
      • Continuous Integration and Deployment: Right now, few Continuous Integration/Deployment (CI/CD) options exist in the WordPress ecosystem.
      • Integration Costs: It can be challenging to integrate some of the latest front-end technologies with a WordPress application.

      Using Gatsby can address some of these limitations. In the following steps, we will show you how to integrate Gatsby with WordPress to take full advantage of both. First, we are going to configure a basic Gatsby project setup. Then, we’ll use it to fetch data from our WordPress site.

      Integrating Gatsby.js with WordPress

      First, we will set up a demo Gatsby project.

      Install the Gatsby CLI by typing the following command in your terminal:

      • npm install -g gatsby-cli

      Next, create a new Gatsby site with the following command:

      To access your site folder contents, type the following:

      Finally, start the development server to begin building your site:

      Installing the gatsby-source-wordpress Plugin

      Assuming that you have a WordPress site already set up, and you would like to have a frontend built with Gatsby.js, all you need to do is pull your existing site data into your static Gatsby site. You can do that with the gatsby-source-wordpress plugin.

      This tutorial uses the default WordPress REST API site, though you are free to use a pre-existing WordPress setup if you have one.

      Inside your terminal, type the following to install this plugin:

      • npm install gatsby-source-wordpress

      Configuring the Plugin

      Inside your gatsby-config.js file, the main Gatsby configuration file, you will add some WordPress-specific configuration options. These include your WordPress site’s baseUrl, the preferred HTTP protocol, and settings pertaining to the Advanced Custom Fields (ACF) plugin. The includedRoutes fields specifies the data we want to fetch.

      Using the demo WordPress site from the step above, the current frontend looks like this:

      For the purposes of this tutorial, add the following code to a file called gatsby-config.js:

      module.exports = {
        // ...
        plugins: [
          // ...
              resolve: `gatsby-source-wordpress`,
              options: {
                  // Your WordPress source.
                  baseUrl: ``,
                  protocol: `https`,
                  // Only fetches posts, tags and categories from the baseUrl.
                  includedRoutes: ['**/posts', '**/tags', '**/categories'],
                  // Not using ACF so putting it off.
                  useACF: false

      Using Fetched WordPress Data

      Once your Gatsby site is fetching data from your WordPress source URL, it’s time to create your site pages. This is done by implementing the createPages API in the gatsby-node.jsfile, which makes the fetched data available to queries from GraphQL. At build time, the gatsby-source-wordpress plugin fetches your data, and uses it to ”automatically infer a GraphQL schema” which you can query against.

      Add the following code to a file called gatsby-node.js:

       * Implement Gatsby's Node APIs in this file.
       * See:
      // You can delete this file if you're not using it
      const path = require(`path`);
      const slash = require(`slash`);
      /** STEP #1: Implement the Gatsby API “createPages”. This is
       * called after the Gatsby bootstrap is finished so you have
       * access to any information necessary to programmatically
       * create pages.
       * Will create pages for WordPress pages (route : /{slug})
       * Will create pages for WordPress posts (route : /post/{slug})
      exports.createPages = async ({ graphql, actions }) => {
          const { createPage } = actions;
          // STEP #2: Query all WordPress Posts Data.
          /** The “graphql” function allows us to run arbitrary
           * queries against the local Gatsby GraphQL schema. Think of
           * it like the site has a built-in database constructed
           *  from the fetched data that you can run queries against.
          const result = await graphql(`
                  allWordpressPost {
                      edges {
                          node {
          // Check for any errors
          if (result.errors) {
              throw new Error(result.errors);
          // Access query results via object destructuring.
          const { allWordpressPost } =;
          const postTemplate = path.resolve(`./src/templates/post.js`);
          // STEP #3: Create pages in Gatsby with WordPress Posts Data.
           * We want to create a detailed page for each
           * post node. We'll just use the WordPress Slug for the slug.
           * The Post ID is prefixed with 'POST_'
          allWordpressPost.edges.forEach(edge => {
                  path: `/${edge.node.slug}/`,
                  component: slash(postTemplate),
                  context: {

      This will iterate through existing WordPress post data.

      Step #4: Creating a post.js Template

      Next, we will create a folder for templates, where you can add files for posts, pages, and layouts. For now, we will create a post.js file to fetch posts from our WordPress site.

      Add the following code to the file:

      import { graphql } from 'gatsby';
      import PropTypes from 'prop-types';
      import React, { Component } from 'react';
      import Layout from '../layouts';
      class PostTemplate extends Component {
          render() {
              const post =;
              // STEP #5: Use title and content in Gatsby.
              return (
                      <h1 dangerouslySetInnerHTML={{ __html: post.title }} />
                      <div dangerouslySetInnerHTML={{ __html: post.content }} />
      PostTemplate.propTypes = {
          data: PropTypes.object.isRequired,
          edges: PropTypes.array
      export default PostTemplate;
      // STEP #4: Get current WP Post data via ID.
      export const pageQuery = graphql`
          query($id: String!) {
              wordpressPost(id: { eq: $id }) {

      Examining the Final Result

      To start the development server and view the final result, type the following command in your terminal:

      You will get the link where you can access the site locally, along with other details like the number of posts, categories, and tags that are being fetched.

      Here’s a GIF that demonstrates what this will look like:

      Let’s take a look at this revamped front-end which is now powered with Gatsby.js and a WordPress back-end:

      You can see how our application is only fetching the required data from the WordPress site. This includes posts, tags and categories. To retrieve other types of data like widgets or comments, you will need to add the appropriate values to the includedRoutes option.


      By following this tutorial, you now have a WordPress application backend integrated with a Gatsby.js frontend. Gatsby provides a fast web experience and brings with it added benefits that can enhance your existing WordPress site. You now have a platform for further experimentation with using Gatsby to power your site,

      Source link