Can only access from localhost

Can only access from localhost

autor Ken Sims -
Počet odpovědí: 16

First let me appologize if this has been answered in other posts.  After many serarches on the forum and via Google I have found many references to this problem, but have not found a permenant solution that will work for me.

This is a new installation of Moodle 2.0.1+ (Build: 20110209) on a new install of Ubuntu 10.10 with GUI desktop installed.
It wasn't a "pretty install", but I have been using Moodle for several years and have done many installations so I was able to patch together an installation that seems to work.  In short, I attempted the apt-get install of Moodle knowing the issues with PHP5 and Moodle 1.9.  That install presented me with a blank page.  I then dropped all the tables in the DB and replaced all files in the moodle directory with Moodle 2.0.1 files.  Modified the config.php file approriately and ran the installation.

Result: I have a working moodle site as long as I am on the Ubuntu server and accessing via http://localhost/moodle.  If I attempt to access it via http://ipaddress/moodle, I get a message "Incorrect address detected.  This server may be accessed only through http://localhost/moodle address, sorry"  It then redirects to localhost and displays the working Moodle site.

When attempting to access from another computer on the same internal newtork with appropriate IP adddress and subnet, I get the same message, but it obvously can not redirect to localhost, so fails to locate the site.

I have modified the config.php file to have wwwroot as each of the following.

'http://localhost/moodle';
'http://ipaddress/moodle';   (where ipaddress is the correct ip for the server)
'http://._SERVER['SERVER_NAME']/moodle';   (as suggested in one post)

I ran the replace.php to change all localhost to ipaddress.

Nothing changes the behaviour.

My past experience with Moodle tells me this issue has been resolved since most of the posts I found were about ver 2.0 from months ago.  I'm hoping that this post will make finding the solution easier for others.

Thanks,

Ken

Průměr hodnocení: -
V odpovědi na Ken Sims

Re: Can only access from localhost

autor Colin Fraser -
Obrázek: Documentation writers Obrázek: Testers

Has the machine a static ip address? It should have but you do not specifically say that it does. Does the host machine recognise its own ip address? The config file should read something like:

$CFG->wwwroot   = 'http://192.168.1.1/moodle';

or whatever your static ip address is. That has never not worked in the past, for me, except when the network card had an intemittent fault, a dry joint I think, but replaced the network card and all issues fixed.

V odpovědi na Colin Fraser

Re: Can only access from localhost

autor Ken Sims -

Yes.  The ip address is static and the server (host) recognizes its address.

Remote machines can access the web site at the ipaddress,  http://ipaddress, but not Moodle installed at http://ipaddress/moodle.  Doesn't seem to matter what is in the config.php file for wwwroot.

If you note the error message, it is coming from Moodle.  The message displayes even when accessing the moodle site from the server desktop, but redirects to "localhost" corrrectly.

When not on the server desktop, the same event happens, but of course can't redirect to "localhost" from a remote workstation.

 

V odpovědi na Ken Sims

Re: Can only access from localhost

autor Jon Witts -
Obrázek: Plugin developers Obrázek: Testers

My recommendation would be to drop the entire apt-get install of Moodle;

install apche, php5 and MySQL from apt-get one by one; then install Moodle manually.

The Moodle deb package is known to have a few bugs at the moment; and you will have a far more stable and sustainable system installing all of the elements separately.

By the way, we are running Moodle 1.9 on Ubuntu 10.04 with no issues to do with PHP 5 at all...

V odpovědi na Jon Witts

Re: Can only access from localhost

autor arif papa -

Hi Moodlers,

I am a new comer in the Moodle world. I just finished installing Standard Moodle 2.02 with XAMPP on Windows server 2008. I can view moodle page on the server, however I can not access it on with any client PC.

I have done what has been suggested above but the problem persists. I am beginning to think if it is Windows security issue or not.

Please I need help.

Thanks in advance.

V odpovědi na arif papa

Re: Can only access from localhost

autor Vaneer Randhawa -

open Moodle configuration file in notepad and replace localhost with the ip of your machine. This worked see coded below.

 

 

<?php  // Moodle configuration file

unset($CFG);
global $CFG;
$CFG = new stdClass();

$CFG->dbtype    = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'root';
$CFG->dbpass    = '';
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbsocket' => 0,
);

$CFG->wwwroot   = 'http://10.124.232.24/moodle';
$CFG->dataroot = 'C:\\wamp\\moodledata';

V odpovědi na Colin Fraser

Re: Can only access from localhost

autor Fran Saez -

Hi, thanks for the solution.

works fine in my local moodle platform,

I just replaced the line 

//$CFG->wwwroot = rtrim(strtolower($app),"/");
$CFG->wwwroot = 'http://172.16.0.1/moodle';

in the config.php file.

I've installed moodle in a IIS server.

Regards

Fran

V odpovědi na Ken Sims

Re: Can only access from localhost

autor Brian Holbert -

I have a very similar issue, from what I have read this has to do with security in moodle.  I've been running 1.9.X for some time now and just decided to upgrade to 2.X recently.  I rent space on a godaddy linux sever and have multiple web sites I server from there.  The main ip is not the one is use for Moodle, I wanted to make a simple domain name to get to my moodle install so I pay for a separate domain name and forward from there to my moodle install.  This was never and issue until moodle 2.

 

My wwwroot is the location on the server to access the direct address to my moodle install through the server domain name and I have my domain name pointing at the direct address to my moodle install through the server domain name however when you use my domain name now I get the "Incorrect access detected, this server may be accessed only through "the direct address to my moodle install through the server domain name" address, sorry. Please notify server administrator. (Continue)" and it loads Moodle and everything works fine.

Now consider how limited my access is to the godaddy server I have it on (yes I know how to host from my own computer, and did so for many years) is and I am going to continue using godaddy what can I do to make it so Moodle stops throwing that error outside going into the code and changing the behavior of the message?  This should be simple but i can't find one place to say "I'm going to point at moodle from here also".

 

This is an extremely common issue, when you search the error tons of moodle servers come up with the issue and there are plenty of people asking the same question with answers that tell you to configure it differently with dns settings and such.  Anyway I hope someone can answer this question I've been searching for 2 weeks before I decided to post about it.

V odpovědi na Brian Holbert

Re: Can only access from localhost

autor Rick Jerz -
Obrázek: Particularly helpful Moodlers Obrázek: Testers

I am not a system administrator, but I do run my Moodle on a GoDaddy Linux (VDS) server.  I had no problem getting 2.0 installed, and even have 2.1 installed for experimentation.

I can type http://domain_name/moodle and my Moodle shows itself.  From your description, I think you are wanting to type http://domain_name and have Moodle show itself.  Well, this could be a little tricky since the domain wants an index.html file to present.

Might you be able to create a simple index.html webpage that redirects to the moodle application?  There would only be a short delay.  You probably know how to write a redirect webpage, but let me know if you don't.  I think I have at least one example.

 

V odpovědi na Rick Jerz

Re: Can only access from localhost

autor Brian Holbert -

My moodle works just fine, it just starts by throwing up a message saying you shouldn't be access the page using domain X you should use domain Y then it redirects you to the index page.  From what I am reading 1.9 allowed this type of forwarding but 2.0 doesn't because it caused "weird problems" in 1.9.  Anyway it's simply a warning message because moodle recognizes you are accessing wwwroot from a place that isn't wwwroot.

V odpovědi na Brian Holbert

Re: Can only access from localhost

autor Brian Holbert -

Ok for the error "Incorrect access detected, this server may be accessed only through "the direct address to my moodle install through the server domain name" address, sorry. Please notify server administrator. (Continue)" when forwarding from another aaddress here is the solution.  Moodle 2.0 doesn't allow you to drop the www from the wwwroot from xxxx.xxx/moodle/ you have to use www.xxxx.xxx/moodle/ (this has been covered in other posts).  However what is different is specifically for Godaddy hosting (and possibly others).

 

Ok for those forwarding on Godaddy.  When you choose the location using the godaddy forwarding system it doesn't add www to the front of the domain.  So I was forwarding from www.xxxxx.xxx to xxxxx.xxx/moodle/ but moodle requires you forward to www.xxxxx.xxx/moodle/ if that is what your wwwroot says so I went into the domain name account for Godaddy and manually added the www to the front of where I was forwarding and the problem was solved.

V odpovědi na Brian Holbert

Re: Can only access from localhost

autor Dylan Cleghorn -

I was getting this error.  My config.php points to http://mysite.com, so http://www.mysite.com was giving the error.

My webhost host has cPanel, so I just used the REDIRECT option.  I created a permanent 301 redirect so that http://www.mysite.com redirects to http://mysite.com.  I checked "Only redirect with www."

My cPanel has the redirect button in the DOMAINS section - with subdomains, addon domains, etc.

Hope this helps somebody out there. 

V odpovědi na Dylan Cleghorn

Re: Can only access from localhost

autor Muhammad Umair -
I have changed the wwwroot address withmy machine as $CFG->wwwroot = 'http://192.168.1.12/moodle'; But now its not working...But before this it was working and still i am unable to access through other computer