0

I installed Apache in Ubuntu Desktop for working with Moodle, I want the Moodle website in var/www/html to be accessible by the computers connected in the same Wifi network. But after some google searches and following some online answers, when I access http://192.168.1.14/moodle from another laptop connected to the same wifi I am getting:

Unable to connect. An error occurred during a connection to localhost.

I allowed Apache2 in ufw using:

sudo ufw app list

Status: active

To                         Action      From
--                         ------      ----
Apache                     ALLOW       Anywhere                  
Apache Full                ALLOW       Anywhere                  
Apache (v6)                ALLOW       Anywhere (v6)             
Apache Full (v6)           ALLOW       Anywhere (v6)   

My ports.conf file at /etc/apache2/ports.conf:

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 80
Listen 8080



<IfModule ssl_module>
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

ifconfig result from my desktop where I am using Apache:

enp2s0: flags=4099&lt;UP,BROADCAST,MULTICAST&gt;  mtu 1500
        ether b4:2e:99:44:ba:c4  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10&lt;host&gt;
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 22208  bytes 4472901 (4.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 22208  bytes 4472901 (4.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlx502b73ebe00e: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet 192.168.1.14  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::34e8:344:9f8e:ed62  prefixlen 64  scopeid 0x20&lt;link&gt;
        ether 50:2b:73:eb:e0:0e  txqueuelen 1000  (Ethernet)
        RX packets 2620624  bytes 3583900946 (3.5 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1265305  bytes 146961762 (146.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Edit: My laptop IP was 192.168.1.12

1
  • 1
    You have stated that you have tried to access http://192.168.1.14/moodle. Did you try the same with https instead of http? From the error message you have shown, it seems very unlikely that this could be the problem, but it might be worth a try.
    – Binarus
    May 19, 2022 at 6:19

1 Answer 1

0

Make sure your Moodle "wwwroot" config parameter points to the correct address. Moodle will always try to redirect visitors to what it thinks should be its "correct" address, so if the wwwroot was originally set to e.g. "localhost" then Moodle will keep redirecting all visitors to localhost.

Assuming you want to access the site by IP address (i.e. you don't have DNS set up yet), config.php should say something like this:

<?php
$CFG->wwwroot = "http://192.168.1.14/moodle";
1
  • Thanks a lot. This solved the problem! I can access Moodle from another computer through Wifi
    – egp_s2s
    May 19, 2022 at 7:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .