Sun Jun 10 2018 15:17:54 GMT-0400 (EDT)

Fixing The “WordPress Needs Access to Your Web Server” Error

Throughout the tenure of your WordPress career, it's likely that you'll run into the error message displayed above: "WordPress needs access to your web server."

This is an error that occurs when file permissions and ownerships are set incorrectly on your site's server, resulting in an annoying pop-up that'll force you to enter FTP credentials each time you'd like to make a change to your site and its plugins. How to fix it depends on whether or not your site runs on a VPS or shared host—below are typical solutions for both.

Methods and Solutions

For VPS Hosts (AWS, Digital Ocean, Linode):

To bypass the error, we essentially need to do one thing: ensure our project's ownership and permissions are set correctly.

To do so, start by changing the ownership of your project (and everything inside of it) so that it's owned by whatever user your web server is running as. NGINX typically runs under the user www-data, while Apache typically runs under the user apache.

To change your project's ownership, SSH into your server and use one of the following commands based on which web server you're using:

NGINX Servers:
sudo chown www-data:www-data my-project -R
Apache Servers:
sudo chown apache:apache my-project -R

Your problem may be fixed after doing this, but if not, you'll also need to ensure that your project has file permissions of 755, meaning that NGINX or Apache have the ability to write files to your server. You can do just that with the following command:

NGINX and Apache Servers:
sudo chmod 755 my-project -R

Once your project's ownership and permissions are set correctly the error should disappear, allowing you to install and update plugins as normal again.

For Shared Hosting Providers (GoDaddy, HostGator, Bluehost):

If your site is currently running on a shared hosting provider such as GoDaddy, HostGator, or Bluehost, it's unlikely they'll provide you the permissions to change the ownership of your files to anything other than your own username. However, the issue most likely lies in the project's permissions, rather than its ownership.

Search within your providers interface for a location to change file permissions (each provider is going to be different). Once found, change your project and its content's permissions to 755—the error message should disappear just as it would with the VPS solution above.

If that still doesn't fix the issue, then I recommend getting in touch with your hosting provider's support team, they're almost always able to help in such situations and typically get the job done rather quickly.

Step-by-Step Solutions

Sometimes I encounter these problems again in the future, yet I don't always remember how to solve them. These step-by-step solutions should be helpful for anyone who understands the problem and just needs a quick reminder on how to solve it.

For VPS Hosts (AWS, Digital Ocean, Linode):

  1. SSH into your server ssh username@ip_address
  2. cd to the root of your project directory: cd var/www/ (this is the default location for NGINX servers)
  3. Check the ownership of your project's directory with: ls -l
  4. If project is owned by something other than www-data:www-data (NGINX) or apache:apache (Apache), change it's ownership with:
    1. NGINX Servers: sudo chown www-data:www-data my-project -R
    2. Apache Servers: sudo chown apache:apache my-project -R
  5. Test whether or not the error is still popping up on plugin install or update
  6. If not, also change your project's permissions to 755 with the following:
    1. NGINX and Apache Servers: sudo chmod 755 my-project -R
  7. The "WordPress Needs Access to Your Web Server" error should be gone after correct ownership and permissions are given

For Shared Hosting Providers (GoDaddy, HostGator, Bluehost):

  1. Find tool within hosting provider's interface to change file permissions
  2. Set all of your WordPress project's permissions to 755
  3. The error should disappear once complete

A brief post, but nevertheless useful as this is a problem I've encountered plenty of times in the past, forcing me to sift through countless StackOverflow questions as a result.

For more useful dev content, be sure check out the rest of chriscourses.com for free tutorials, courses, and more. Otherwise feel free to leave a comment if you have any questions, I'll do my best to reply quickly.


Support the Cause

All Chris Courses tutorials are completely free—help support the production of more free blog posts and tutorials via PayPal or Patreon.