Common WordPress Login Issues

wordpress code

Login Problems in WordPress

Getting locked out of your website can be incredibly frustrating. That’s especially true if you’re in a hurry, and need to upload some new content or deal with customer purchases or queries. 

Fortunately, most WordPress login issues aren’t that difficult to resolve. First, you’ll need to determine the source of the issue. Then you can follow a few simple troubleshooting steps, in order to regain access to your website.

In this article, we’ll cover five common WordPress login errors and explain how to solve them. It’s a good idea to back up your site before trying any of these solutions. Then, you’re ready to get started!

1. Error Establishing a Database Connection

When you encounter an error that says something like: “Database connection can not be established”, there could be a few causes. This situation requires some troubleshooting to determine whether the problem is due to a corrupt database, changed or incorrect database credentials, unresponsive servers, or a problem with your wp-config.php file

Solution: Check the WP Config File

There are a couple steps you can take to determine the root cause of a database connection error, and gain access to your site. Before proceeding, you should always create a backup of your existing database.  

Then, you’ll want to determine whether the error is appearing on the front end, the back end, or both. Try logging into your site’s /wp-admin page and see if you get the same error. If you don’t, you’ll likely need to repair your database by adding the following line to your wp-config.php file, just before the “stop editing” note at the bottom: 

define( 'WP_ALLOW_REPAIR', true );

Once you have done that, you can see more settings by going to http://www.yoursite.com/wp-admin/maint/repair.php. There, you can choose to repair or repair and optimize your database:

repair and optimize database

Since you don’t have to be logged in to do this, you’ll want to remove the line of code from your wp-config.php file when you’re done. 

If you do see the same database connection error on your /wp-admin page, then you likely need to check your wp-config.php file for other errors and make sure all of its contents are correct:

wp-config.php file

The wp-config.php file contains the following information about your database:

  • Database name 
  • Database username
  • Database password
  • Database local host

If your wp-config.php file seems in order, you’ll want to move on and make sure that your site’s server is not experiencing an issue. This might involve contacting your hosting provider and asking them if the server is down.

You can also try testing another site on the same host, if possible, to see if the same issue persists. If your site has experienced a sudden increase in traffic, your server might not be able to keep up, and you may need to upgrade your plan. 

If your issues persist, you can also create a testconnection.php file to test the permissions in your MySQL database. Don’t forget to scan all of your files for typos in user names, passwords, and site URLs. 

2. Forgotten Password or Username

Unfortunately, strong passwords can be long and difficult to remember. For that reason, it’s not uncommon for you or another user to forget the credentials for your WordPress account:

forgot wordpress password or username / wordpress login / wp admin login

The good news is that WordPress offers several approaches to resetting passwords and usernames. Depending on whether it’s the administrator or another user who forgot their credentials, there are solutions available for most scenarios.

Solution: Emergency Password Reset

If the basic fixes aren’t working for you and you’re still locked out of your site, however, you can try using the PHP Emergency Script option. To take this approach, you must know the administrator’s username. The administrator will receive an email once the process is completed, as it will change their password.

Then you’ll need to create a file called emergency.php, which includes the Emergency Password Script. Upload it to your site’s root directory using a Secure File Transfer Protocol (SFTP) client such as FileZilla.

Finally, go to http://mysite.com/emergency.php and follow the prompts to reset your password. Don’t forget to delete the emergency file from your directory when you’re done, so it doesn’t get misused. 

3. Syntax Error

All the power and flexibility WordPress offers can make it easy to introduce errors, especially when you’re using code snippets:

wordpress syntax error

While adding custom code to your site is sometimes required during a plugin’s setup process and for various other tasks, mistakes can result in syntax errors.

Solution: Code Repair

In order to remedy a syntax error, you’ll likely need to use FTP to access your website. This kind of error will typically crash your entire site, and lock you out even as an administrator.

Then you can take the following steps:

  1. Write down the error code or take a screenshot of it to reference later if needed.
  2. Connect to your website via SFTP.
  3. Access the last file you edited before the syntax error occurred. If you can’t remember what that was, refer to the error code, as it should reference the offending file. 

Once you find the file, you can remove the code altogether or correct the offending syntax. Then, test your site to ensure that it’s now working properly.

4. Domain Change Errors

If you’ve been working on a site redesign, changed your host or domain name, or installed a plugin that required domain information, it’s possible that you might encounter an error that says something along the lines of: “This site does not exist”.

Solution: Update PHP

There are several places where domain information for your site is stored, both within your site’s settings and its files. It’s important that they all match, in order for your site to be accessible:

update phph in wordpress

To prevent this error, you can make sure to take a few basic precautions when moving your website. If your site appears to have disappeared, however, you can follow this procedure to troubleshoot the issue:

  1. Locate your wp-options.php file in your phpMyAdmin dashboard
  2. Make sure that all references to your site’s domain match exactly, or edit them so that they do. 
  3. If everything matches in the wp-options.php file, WordPress does provide code that you can insert into the wp-login.php file. Then, you can push an update manually by uploading the corrected file to your site.

It’s important to make sure that your domain information matches in your site’s general settings as well. 

5. Cookie Issues

Finally, this is one of the least troublesome errors to encounter while trying to log into your WordPress website. It likely has nothing to do with your actual site, and can be solved relatively easily by taking a look at two elements of your browser settings.

Solution: Cookie Refresh

First, make sure you have cookies enabled in your browser. Then, try clearing your browsing history (including cookies):

refresh cookies

That should do the trick to solve this particular error, and you should be able to log in on your WordPress site without trouble.

The WP Engine Error Log

The more you expand your WordPress website, the more likely you are to run into errors or find yourself locked out. The five issues outlined above are just a few of the problems you might encounter while working on your site

It can be difficult to keep track of all the potential errors and solutions you may have to deal with. Fortunately, WP Engine users have access to a tool that can help immensely. The WP Engine Error Log offers an easy way to keep track of your site’s errors, troubleshoot problems, and find solutions quickly.

Solve Your Problems with WP Engine 

As we’ve seen, there are some common login errors you might encounter when using WordPress. The good news is that most of them are easy enough to fix, especially with the right tools.

If you do encounter domain change issues, forgotten passwords, or database connection errors, you’ll want access to quality resources that get you back on your feet quickly. Here at WP Engine, we can help you keep your site free of problems and running smoothly. Check out our plans, and build with the confidence that you can tackle any error!