Jump to content

localhost not working

Go to solution Solved by ladybug,
52 minutes ago, Needfuldoer said:

Does the user account Apache runs under have permissions to access that folder?

 

1 hour ago, Eigenvektor said:

Which version of macOS are you using? In Monterey the config file should be in /etc/apache2/httpd.conf. Open the file in a text editor, it should tell you which directory it is trying to serve and also where the logs should be written to.

no it's just the index.html where it says it works! was in the default folder and there wasn't such a file (index.html) in the folder I pointed at(technically it's probably fine it's just an html document, apache is probably running fine even if I can't load that document but I wanted everything unchanged), so I called Apple Support and got an employee with macOS Monterey to tell me the default values because I forgot them and now it works! I am seeing the html document that says it works! So thanks to you for telling me about the logs and thanks to Apple!

 

More information needed. What does your configuration look like, what kind of service/website are you trying to provide over Apache?

 

You are certain Apache is running and listening on port 80?

sudo lsof -i -P | grep LISTEN | grep :80

 

If so, check in Apache's logs (access and/or error logs) whether you see any reason why you can't access the site. "You don't have permissions to access this resource" could mean you're trying to serve something that doesn't exist (e.g. the directory containing the .html-files no longer exists or was renamed) or you don't have read permissions to it.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271420
Share on other sites

Link to post
Share on other sites

7 minutes ago, Eigenvektor said:

More information needed. What does your configuration look like, what kind of service/website are you trying to provide over Apache?

 

You are certain Apache is running and listening on port 80?

sudo lsof -i -P | grep LISTEN | grep :80

 

If so, check in Apache's logs (access and/or error logs) whether you see any reason why you can't access the site. "You don't have permissions to access this resource" could mean you're trying to serve something that doesn't exist (e.g. the directory containing the .html-files no longer exists or was renamed) or you don't have read permissions to it.

No,I am talking about the built-in localhost webpage that says it works! when you enable apache on Mac,I don't have websites, I am talking about the server itself. And yes I am sure it's on port 80. It's not running on the www user though since I changed that yesterday to my user but it worked before

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271423
Share on other sites

Link to post
Share on other sites

2 minutes ago, stefanmz said:

No,I am talking about the built-in localhost webpage that says it works! when you enable apache on Mac,I don't have websites, I am talking about the server itself

The "It works" page is just a simply HTML-document that is served from some directory on your machine. So the points above still apply. Check Apache's configuration, check whether the directory that it is trying to serve exists, you (or rather Apache) has read permission to it. And do check Apache's logs, they might provide more insight into what is going wrong.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271429
Share on other sites

Link to post
Share on other sites

2 minutes ago, Eigenvektor said:

The "It works" page is just a simply HTML-document that is served from some directory on your machine. So the points above still apply. Check Apache's configuration, check whether the directory that it is trying to serve exists, you (or rather Apache) has read permission to it. And do check Apache's logs, they might provide more insight into what is going wrong.

And how do I do that? I don't know where they are located. By the way also read the edited message where I said I changed the user. Could that be a problem?

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271434
Share on other sites

Link to post
Share on other sites

2 minutes ago, stefanmz said:

And how do I do that? I don't know where they are located

Which version of macOS are you using? In Monterey the config file should be in /etc/apache2/httpd.conf. Open the file in a text editor, it should tell you which directory it is trying to serve and also where the logs should be written to.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271440
Share on other sites

Link to post
Share on other sites

5 minutes ago, Eigenvektor said:

Which version of macOS are you using? In Monterey the config file should be in /etc/apache2/httpd.conf. Open the file in a text editor, it should tell you which directory it is trying to serve and also where the logs should be written to.

um, ok but I changed only the document root there to a directory I can easily access, and it was workings I don't know

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271446
Share on other sites

Link to post
Share on other sites

11 minutes ago, Eigenvektor said:

Which version of macOS are you using? In Monterey the config file should be in /etc/apache2/httpd.conf. Open the file in a text editor, it should tell you which directory it is trying to serve and also where the logs should be written to.

I found this

[Sun Feb 20 16:16:46.625415 2022] [autoindex:error] [pid 1540] [client ::1:50605] AH01276: Cannot serve directory /Users/home/Sites/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
So how on earth was it working yesterday when I changed the document root? Was it cache perhaps? Because the html page was showing even when I stopped apache and then after a few hours when I tried again it didn't load it because apache was stopped. So ?

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271454
Share on other sites

Link to post
Share on other sites

11 minutes ago, stefanmz said:

um, ok but I changed only the document root there to a directory I can easily access, and it was workings I don't know

Does the user account Apache runs under have permissions to access that folder?

I sold my soul for ProSupport.

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271461
Share on other sites

Link to post
Share on other sites

52 minutes ago, Needfuldoer said:

Does the user account Apache runs under have permissions to access that folder?

 

1 hour ago, Eigenvektor said:

Which version of macOS are you using? In Monterey the config file should be in /etc/apache2/httpd.conf. Open the file in a text editor, it should tell you which directory it is trying to serve and also where the logs should be written to.

no it's just the index.html where it says it works! was in the default folder and there wasn't such a file (index.html) in the folder I pointed at(technically it's probably fine it's just an html document, apache is probably running fine even if I can't load that document but I wanted everything unchanged), so I called Apple Support and got an employee with macOS Monterey to tell me the default values because I forgot them and now it works! I am seeing the html document that says it works! So thanks to you for telling me about the logs and thanks to Apple!

 

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271498
Share on other sites

Link to post
Share on other sites

3 hours ago, stefanmz said:

It's not running on the www user though since I changed that yesterday to my user but it worked before

Please don't do this on anything you put live on the internet. Learn how permissions work and use them properly, they exist for your protection.

 

Keep Apache running as the www user, assign a folder to use as a webroot, changes that folders owner and group to www:www and give it 640 permissions. All files that go inside should also be owned by www:www with 640 permissions.

 

This is done to prevent web users from getting access to your entire filesystem which would be VERY bad.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271645
Share on other sites

Link to post
Share on other sites

16 minutes ago, Master Disaster said:

Please don't do this on anything you put live on the internet. Learn how permissions work and use them properly, they exist for your protection.

 

Keep Apache running as the www user, assign a folder to use as a webroot, changes that folders owner and group to www:www and give it 660 permissions. All files that go inside should also be owned by www:www with 660 permissions.

 

This is done to prevent web users from getting access to your entire filesystem which would be VERY bad.

yup everything is as it was before now.I restored it. I haven't changed any permissions for these folders nor do I know what 660 means. I don't want to deal with linux style permission changing, I am sure the default configuration of macOS is fine. I changed back the user to www and the folder to the default for apache so it's all good. Also it's a local server so doesn't this mean nobody else has access?

Link to comment
https://linustechtips.com/topic/1413213-localhost-not-working/#findComment-15271680
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×