Connecting to localhost on a mac, across a network from a pc

Hi guys,

I currently have a file sharing network set up between my mac and pc.
Now, I have a localhost server running on the mac, and I obviously just browse to http://localhost to test my pages when working on the mac and was wondering how I could browse to the pages (localhost on the mac) from the PC (across the network)… is this possible? If so, what do I need to do?


I’m assuming this is OS X. (I don’t know OS X but it’s based on FreeBSD so this command should work.)

If you have router such as Linksys and are using DHCP, an IP other than is already set. Open a command line prompt window (Terminal Window, I believe) and type ifconfig.

Should get something like this (Note: edited output):

eth0 Link encap:Ethernet HWaddr 00:80:AD:72:E8:9A
inet addr: Bcast: Mask:

lo Link encap:Local Loopback
inet addr: Mask:

Use the number after inet addr: from the eth0 section.

As I said I don’t really know Mac’s so there maybe a different command that does the same thing.


Hi…thanks for the reply… but I actually use that IP address to connect to my mac (for file sharing) over the network, so I am not sure how I could connect to the localhost server?


Presuming the server is not firewalled nor restricted to localhost for some other reason, you just need to enter the IP address of the mac to view it within your local network. Ie, if the IP was, then you would just browse to from the other computer.

Hi… yeah, I already have the mac connected across the network, and have used its ip address to establish the connection (

On the mac, I have all my files (for Apache localhost) in a folder, and have set up a doc root in httpd.conf, so, when on the mac, I open up http://localhost, and it shows me the site that I am testing locally.
If I was to browse to those files (.php) across the network from the pc, and tried to open one of them, then it would open them with dreamweaver, or my pc’s default app.

So, basically, I wanted to be able to open up the site to test it from the pc , without always having to upload my modified files to my sites remote server for testing.

Does this make sense?


Have you set up personal web sharing in system preferences?

Yes, I think so…I have web sharing and Windows file sharing both set up…

Do you see the default Apache page when you go to http://mac-ip-address/?

No. You are connecting to a file share using \\\ShareName. What you need to do is open a http connection. The best way to do this is to explicitly state “Hey, windows, this is a http connection!” by typing in your windows browser.

Unless the mac is not properly configured to accept http connections from outside of localhost, that is. In which case, you will need to tweak the apache setup to listen on other addresses.

wwb_99: Thanks for that…I will give it another go
Rob_D: I only see the folders on my Mac when I go to that address…

Thanks again, I will post whethter it was successful or not

OK, I tested browsing to the directory on my mac (from the pc).
I had a file “index.php” in that directory. When I browsed to that folder (from the pc, in a browser), I was shown the directory itself (files and folders) but, I created a file, “index.html” and saved it to that directory and when I browsed to it again, I was able to see index.html rendered correctly.
So, I can only assume that I will need to tweak Apache (as you mentioned).
I added my pc’s ip address to the following lines in Apache’s HTTPD.conf:

# Listen: Allows you to bind Apache to specific IP addresses and/or
   # ports, instead of the default. See also the <VirtualHost>
   # directive.
   # Change this to Listen on specific IP addresses as shown below to 
   # prevent Apache from glomming onto all bound IP addresses (
   Listen 80
   #my pc's ipaddress

Is that correct? or do I also need to add the sharename to the end of that? As I did not get any improved results.

I am using the MAMP package, and not OSX’s built in Apache…


There is no share here–I still think you are browsing incorrectly. Do not open windows explorer and go glicking on My Network Places. Do open a web browser and type in the IP address. You need to hit the machine over port 80, rather than whatever SMB is running on.

The reason the html file works is that it does not need server side processing, whereas the php stuff does not work is that you are still browsing to a network share, not hitting the web server.

Regarding the configuration, I am not really an apache guy, but it would help if Apache was listening on the same IP address the mac is using–which you indicated was above and the config has it as .6.


but it would help if Apache was listening on the same IP address the mac is using–which you indicated was above and the config has it as .6.

OK, from what I understood, I needed to configure apache to listen to the PC (ip address… My bad, I will try that when I get home…:slight_smile:

As for the browsing issue, I was definitely using the browser, and had entered the address


The file view I got was not the usual Windows Explorer view, it was my servers directory view, with linked files etc… ie: what you would normally see if you went to a website with no index file for example…

Thanks again.

No, this is not where you should go. Your webpages should be in Macintosh HD/Library/WebServer/Documents. By default is only here that PHP pages will be parsed.

When you enter (just that and nothing else, don’t bother with file paths for the moment) in your web browser, you will either see an apache page, index.html, or the parsed index.php.

I have several folders in my Documents folder for various web projects I am working on. For ex., I have a folder called aom which contains the files for a web project and I use to run the index.php file in that folder.

Let me know if you need more info.

You see, when you go to http://localhost on your Mac the browser gets the pages from the websever location (Macintosh HD/Library/WebServer/Documents). So, when you put in your PC browser the webserver will automatically serve the same default page from the same location (Macintosh HD/Library/WebServer/Documents) to the browser.


Right. The problem is now sorted!
Thanks everone for your help.
@Rob_D: As you pointed out, I simply need to browse to that address - - and the browser loads whichever page I have set as my document root in httpd.conf

Thanks for all the help.