Login to Wordpress Admin via IP but not domain name

I can login to wp dashboard using my ip address, but not my domain name, i.e:

12.345.67.89/wp-admin works ok doesn’t work

I just get taken back to the login page again when I enter correct login details. (If I enter incorrect ones I get the usual error message).

I’m assuming it is some settings somewhere, but I don’t know where.

I’ve edit my wp-config file:

define(‘WP_HOME’,‘’); define(‘WP_SITEURL’,‘’);

Is there something else I’m missing?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Thanks for the tips.

I did all that and I’ve managed to get it working. I think in the end it was something to with the write permissions for .htaccess.


Using define() to set the constants should be all that’s required, unless the Apache configuration is using the IP as ServerName instead of your actual domain.

You can check the file in /etc/apache2/sites-available that corresponds to your website to see how the VirtualHost is setup. You’ll want to check ServerName and ServerAlias to see what is listed as the domain/IP.

Also make sure your domain is setup with the correct A entry pointing to your server IP.

Beyond that, clear your cookies/cache before trying to login again, just to make sure that isn’t the issue.

Thanks to @robertjamespeacock, this is working on my wordpress webiste. But I still in confusion of is this work for security. How effective is this? I did blocking ip address using .htaccess file.