My Moodle site redirects to 127.0.0.1! (Moodle 3.6.3)

My Moodle site redirects to 127.0.0.1! (Moodle 3.6.3)

by x HyperSource -
Number of replies: 3

Hello everyone,

I have a Moodle website hosted at my house using XAMPP. I port forwarded port 80 (TCP), and tried to connect to my website from a different network using my external IP Address (my Moodle site is located at C:\XAMPP\htdocs\start\moodle). I tried typing in [IP Address]/start/moodle, but instead of connecting, it redirected me to 127.0.0.1/start/moodle. Any ideas on why this might be happening?

Thanks,

xHyperSource.

Average of ratings: -
In reply to x HyperSource

Re: My Moodle site redirects to 127.0.0.1! (Moodle 3.6.3)

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moodle will only allow itself to be accessed using the address defined in $CFG->wwwroot. Presumably you have this set to http://127.0.0.1/start/moodle, so trying to access the site via your external IP instead will result in a redirect.

In reply to Mark Johnson

Re: My Moodle site redirects to 127.0.0.1! (Moodle 3.6.3)

by x HyperSource -

Thank you! I'm pretty sure this fixed my problem. I'm kind of new with Moodle so...

Also one more question, is there a way to make my moodle site accessible from both 127.0.0.1 and using my public IP address (other than hosting it somewhere else)?

In reply to x HyperSource

Re: My Moodle site redirects to 127.0.0.1! (Moodle 3.6.3)

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Not exactly, but you can make it accessible from both inside and outside your network.

The simplest way would be to sign up for a Dynamic DNS service like afraid.org. This will give you a domain name (e.g. mymoodlesite.afraid.org) that always points to your public IP address, even when your IP address is changed by your ISP. Set your $CFG->wwwroot to use this domain name in place of your IP address.

Then, on your machine, add a rule to your hosts file to point mymoodlesite.afraid.org to 127.0.0.1. This means that when you go to that domain name on your machine, it will go to your local IP address, but on any other machine it will go to your public IP address. In either case, Moodle will see that you're accessing it at the configured domain name, so it will be happy.