Mithril
Mithril

Reputation: 13748

localhost can access wordpress but 127.0.0.1 cannot

OS :ubuntu
when I enter http://127.0.0.1/wordpress,
show error:

Neither /etc/wordpress/config-127.0.0.1.php nor /etc/wordpress/config-0.0.1.php could be found. 
Ensure one of them exists, is readable by the webserver and contains the right password/username.

but http://localhost/wordpress can access

I had used command bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost which may cause this error.And I also want to figure out what that command means.

Upvotes: 0

Views: 6424

Answers (4)

Sanjeev
Sanjeev

Reputation: 1866

Try to see if the mapping is set to resolve localhost to 127.0.0.1

try:

$ sudo chmod 644 /etc/hosts
$ cat /etc/hosts
127.0.0.1 localhost

Upvotes: 0

Frederick Ollinger
Frederick Ollinger

Reputation: 777

As per the above answer, this did not work, one Debian Jessi 8.1, because /etc/wordpress/config-default.php does not exist.

However, I did:

ln -s /etc/wordpress/config-dev.php /etc/wordpress/config-localhost.php

which got me past this hurdle. However, the next problem is " As per the above answer, this did not work, one Debian Jessie 8.1, because /etc/wordpress/config-default.php does not exist.

However, I did:

ln -s /etc/wordpress/config-dev.php /etc/wordpress/config-localhost.php

which got me past this hurdle.

However, the next problem is "Error establishing a database connection" which is beyond the scope of this question.

Upvotes: 0

Mithril
Mithril

Reputation: 13748

finaly,I figure it out myself.

  1. alter siteurl column under wp_options table,set localhost to host machine ip.such as http://192.168.2.16/wordpress
  2. alter home column under wp_options table,and set localhost to host machine ip,as above.
    (If one don't do 1 and 2,you can not see img )
  3. sudo ln -s /etc/wordpress/config-localhost.php /etc/wordpress/config-default.php (this is because at last wp-config.php looks for config-default.php)

then,this problem solved~

Upvotes: 2

Jackson
Jackson

Reputation: 3518

Your Wordpress database is probably configured for 'localhost' You need to change a couple of table entries to make it work

Upvotes: 0

Related Questions