Cant access MAMP server from other computers on my network - mamp

I have setup MAMP as a web testing environment on my MacBook Air on my network (its local ip address is 10.0.0.10). It operates fine on that on the MacBook Air, i.e. localhost:8888 takes me to the Apache root directory.
Now I want to do some testing from a Windows machine I have on the same network. From the windows machine I typed in the following 10.0.0.10:8888 into Firefox. It says it is connecting for ages, then sometimes after a while some content shows, but it still says it is loading.
I can't work out what is going on. I have no firewall on the MacBook Air. The https.conf file is set to listen to port 8888.
Is there anything special that I need to do with a MAMP server to be able to access it on other machines?

Worked it out. While the machine serving MAMP didn't have a firewall, the Windows machine did and obviously the port 8888 was not getting through :P.
On a side note I am working with Wordpress and needed to update the wp-config.php file and the database. localhost needed to be updated to reflect my IP address.

In order to access the MAMP on a network, you suppose to Allow the port in Windows Firewall to allow all connections. On a windows server instance

Adding to your point...
Setting MAMP to use ports 80 for apache and 3306 for mySQL
I had the same issue on my machine and found this post doing a search but it didn't include how to fix it.
thanks!

For those who will land on this page in future and want to access their MAMP server by IP, add this as the very first <VirtualHost *:80> either with the default MacOS Apache server or with MAMP (for MAMP, put it after NameVirtualHost *:80):
<VirtualHost *:80>
DocumentRoot /path/to/web/root
</VirtualHost>
(where /path/to/web/root = /Applications/MAMP/htdocs for MAMP, & = /Library/WebServer/Documents for the default MacOS Apache server)

Related

Re-mapping localhost in Windows on Parallels for Mac

I have just started using Parallels for Mac, and am attempting to debug a locally running web application on my host MacOS machine.
I have figured out that I can connect to the my host via 10.211.55.2 in the browser in my virtual windows machine.
What I'd like to do is to instead connect via localhost and have this routed through to the 10.211.55.2 ip instead.
I tried editing my windows hosts file with an 10.211.55.2 localhost entry but this made no difference.
Is this possible to do?
localhost is hardcoded in many libraries. In theory it should be possible, but it would break a lot of things, including not being able to boot up the system. Connections to localhost are used frequently for interprocess communication throughout the system, so there's more to it then you using it for testing websites. Just go with another name.

Unable to access jetty server with local IP address

I have configured jetty-maven-plugin in my eclipse Mars and I can run the server using jetty start and stop goals. I can able to access the website using http://localhost:8080/myapp but not using local IP address(i.e., http://192.168.0.5:8080/myapp) from my own computer or other computers connected in the same network via LAN and Wi-Fi.
As mentioned as a solution in these posts,
how to make jetty server accessible from LAN?
Configuring Jetty to accept connections from all hosts
I configured the server host to 0.0.0.0 from localhost to listen on all hosts. With this setting I can see on server start log,
INFO:oejs.AbstractConnector:Started SelectChannelConnector#0.0.0.0:8080
and it works only on http://localhost:8080 but it's not accessible from http://192.168.0.5:8080.
I also tried running that if the interface is accessible using the Networks Interface Listing as mentioned in this comment. and I got,
Display name: NETGEAR WNA1000M N150 Wireless USB Micro Adapter
Name: wlan4
InetAddress: /192.168.0.5
I also tried turning off my Windows Firewall/antivirus but din't help. My jetty version is <jetty.version>9.3.0.M1</jetty.version> and JDK 1.7. What could be the problem? Any help is appreciated.
McAfee Endpoint Security was the culprit here. It was blocking the requests with IP addresses from my very own computer. Turned off the firewall inside the Antivirus and I was able to access the site with http://192.168.0.5:8080/mysite from the browser and other devices connected through the network.
Sometimes some other program opens your port on external address before you do that with Jetty. It will receive all traffic instead. On Windows you will not know it if you reuse port (that is Jetty's default behavior). Check with netstat -ano what is the IP of the process that is indeed listening on 0.0.0.0:8080. Verify if it is your Jetty process only.
Then try connecting with telnet or netcat and see if you can open the connection and what is the response.

Keep port in url when usung redirect in Zend Framework

I have a Windows development machine with an Ubuntu VM set up via vagrant. The VM has Nginx running on port 80 and the Vagrant configuration maps port 8080 on the host Windows machine to port 80 on the VM. For various reasons the project that I'm working uses 127.0.0.1 instead of localhost so, in my browser on the Windows machine, I hit a URL such as:
http://127.0.0.1:8080/foo/bar/baz
The application on the VM is built with Zend Framework 1.12.
If I click a link that has an href="/foo/bar/baz" then all is fine and I go to:
http://127.0.0.1:8080/foo/bar/baz
However, if in one of my controllers I use a redirect to "/foo/bar/baz" then the browser loads:
http://127.0.0.1/foo/bar/baz - i.e without the port in it.
If I then manually edit the URL in the browser's address bar to add the port and hit enter then the page comes up correctly.
I've tried various ways of doing the redirect programatically in ZF, and even tried typing a hard coded URL into the code, but whatever I do it always strips out the port component when the redirect takes place.
Any ideas/suggestions as to how to keep the port in the redirect would be much appreciated.

how to view "localhost" on my iPod touch

I have a website I am building on localhost:
http://localhost/my-website
I need to test it on my iPhone, but I'm not sure how to go about it. Do I just change my httpd-vhosts.conf file, and, if so, what are the settings?
Assuming that your development machine is called my-macbook-pro, you should just be able to navigate to http://my-macbook-pro.local/mywebsite on your iPhone.
To expand slightly on Richard J. Ross III's answer, "localhost" is a name used to refer only to the local computer. In order for your iPhone to be able to access content on that machine it must:
Have an IP address on the same network as the server machine.
This can be achieved by connecting the iPhone to a wireless access point that is on the same network as the PC, or by creating an ad-hoc wireless network between the two devices.
Respond to HTTP requests from network clients.
Assuming the server and the iPhone are on the same network, it should be possible for traffic to flow between them. However in order for your web content to be visible to the iPhone, the web server must also be configured to respond to requests made to the server machine's IP address.
This is not normally a problem as web servers are commonly configured to respond to HTTP requests sent to any of the machines IP addresses. It is possible that a server could be configured to only respond to local requests, however this is not a typical default setting
How you check or modify this setting is dependent upon the HTTP server software you are using. As this information is not specified I will include instructions for Apache2 as this is a very common choice of HTTP server.
Apache's Listen Directive
Apache's main configuration file is httpd.conf and it is located in the conf subdirectory of your Apache directory. The location of your Apache root directory will vary depending upon what operating system you are using and whether or not a custom location was chosen at installation.
The httpd.conf file contains a directive named Listen which controls the interface (IP address and port) on which Apache listens for incomming HTTP requests.
The default form of this directive is commonly
Listen 80
This specifies that the machine will respond on any of it's IP addresses to requests made on port 80, which is the default port for HTTP traffic.
You can modify the Listen directive to use any address associated with the machine including the loopback address (127.0.0.1) which the name localhost resolves to.
If Apache is set up to only listen on the loopback address then your server machine will only respond to requests made on the local machine. In this configuration, your Listen directive will look something like:
Listen 127.0.0.1:80
If this is the case, you will need to change to either listening on all addresses, as in the example above, or listening only on the address used by the iPhone to communicate with the server machine.
100% working solutions
(for linux + apache + vhosts)
If you are using vhost (several sites on the same server apache) the next several tips can help you view your local websites on mobile:
1) VHOST edit -You should go to /etc/apache2/sites-available/ on your server. There can be several files .conf, each file contain a virtual host configuration for apache. Default file will look like 000-default.conf. Open it (or another one) with admin permissions sudo. In that file you should see something like this:
<VirtualHost *:80>
ServerName auction.dev
ServerAdmin test#test.com
DocumentRoot /var/www/public_html/html
ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/access.log combined
</VirtualHost>
2) XIP.IO - this special service (its totally free) can help you. You should add to .conf file next line - ServerAlias auction.dev.*.xip.io, after this operation your file will look like this:
<VirtualHost *:80>
ServerName auction.dev
ServerAlias auction.dev.*.xip.io
ServerAdmin test#test.com
DocumentRoot /var/www/public_html/html
ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/access.log combined
</VirtualHost>
After editing you should save this file and restart apache with command sudo apachectl restart.
3) View from mobile - You need to know ip of your server, in my situation ip = 192.168.1.247. Now in your mobile browser just type auction.dev.192.168.1.247.xip.io and you should see your local website.
I'm working with xampp. localhost works on port 8080.
I just find my ip with ipconfig and surf to http://10.0.0.1:8080.
That easy!
If you just want a better feel of the native behavior instead of just browser dev tools you can use the iOS simulator and type localhost:xxxx in safari app.
For OSX, go to System Preferences / Sharing. There, you can find and change the name of your computer. In the same section, you also have to enable "Internet Sharing" service with "iPhone USB" port.
Then you can view your website at http://{ computer_name }.local/my-website.
When you connect your ipod with the cable to your macbook the device appears in safari on your mac in the menu under developers. When you click this option you can see exact the same as you can on your ipod.
Following these steps worked for me:
https://mtm.dev/iphone-localhost-mac
It is based on Internet Sharing via USB and setting & using the device_name which is then used as mentioned as <device_name>.local:<port>

make virtual host available through local network for iphone

I'm building a site on my localhost with a virtual host (mynewsite.com). Instead of uploading files to an actual server and I'd prefer to just test locally. I have the virtual host working on my desktop, I just want it to be available so I can see it on my iPhone or any computer on my network. So if I go to mynewsite.com on my iPhone it will display the site from my localhost. I think I need to do port forwarding but I'm having difficulty figuring it out. I'm on a Mac with MAMP.
How do I make the virtual host available to my iPhone through my Linksys router for testing?
My httpd.conf in MAMP looks like:
<VirtualHost *:80>
DocumentRoot "/Users/jaysonp/Sites/mynewsite"
ServerName "mynewsite.com"
ServerAlias *.mynewsite.com
...
Then in my host file I have:
127.0.0.1 mynewsite.com
I should note that I can't just hit the ipaddress on my iPhone, there is code that checks against the domain name for the site to work.
Thanks!
Please see my answer here. But basically, you just have to modify the Wifi settings in your iPad to use the IP address of your development machine as an HTTP proxy.
You can use application to edit hosts file on the devices. Use iFile application. You can add more any hostname. You can see some picture here but I wrote in my language.
http://www.anop72.info/iphoneipad-เรียก-url-vhost-ทำอย่างไร/
Hope this helps.
You just need to change the host file of respective machine on which you want to see your virtual host.
For Example:
(in Linux and macOS ): /etc/hosts
(in Windows ): c:/windows/system32/drives/etc/hosts
(in Android ): Android is also the part of linux so the host file location is same in android too. But you need root access to change the host file.
(in iOS ): (anyone who knows can edit here!!)
Open the host file and
192.168.1.70 mynewsite.com
192.168.1.70 is the ip address of the machine in which your project is running on a virtual hosting -> mynewsite.com
All of the other devices must be connected to the same network .
Just use the IP address of your virtual host. If your iPhone is on the same local network as your [virtual] host - the IP address will work fine.
I am not quite sure how you are defining "virtual" host - i.e. are you using Xen or VMware or something - or just running a web service on your dekstop?
If it is the former - you need to set up the IP services through Xen/VMware - if it's the later - its you desktop machine's IP address.