Yosemite localhost displays 404, but computer name displays "It works!" - macos

I've been having a bit of a headache since upgrading to Yosemite. Typically, I run a gulp or grunt connect package that spawns a Node server on port 9000. I hit the page by going to http://localhost:9000. However, after firing up the server, that URL gives me a 404.
I ran $apachectl configtest and got the following:
"AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using jake.local. Set the 'ServerName' directive globally to suppress this message"
"jake.local" is my computer name. Coincidentally (or maybe not?), when I go to jake.local:9000, I get my website and no 404.
I'm not an Apache expert by any means, but I have followed this tutorial with no luck: Apache localhost/~username/ not working... and have ended up just reverting my httpd.conf because the instructions won't work for me. I'm starting to think I might have a different issue, as it's my understanding that out of the box, Yosemite should just live me a "It Works!" when I hit http://localhost
I'm not sure how to proceed, but I'd like localhost to work again and not have to use my computer name. How would I go about doing this?
Any help would be greatly appreciated. Thank you!
EDIT:
127.0.0.1:9000 also gives me positive results. In my host file, I have:
127.0.0.1 localhost

After many hours of searching, I discovered there's a line in my hostfile leftover from Mavericks:
#in /etc/hosts
fe80::1%lo0 localhost
If you have that, remove it.

Related

MongoDB no suitable servers found

I'm having trouble connecting to a replica set.
[MongoDB\Driver\Exception\ConnectionTimeoutException]
No suitable servers found (`serverSelectionTryOnce` set):
[Server closed connection. calling ismaster on 'a.mongodb.net:27017']
[Server closed connection. calling ismaster on 'b.mongodb.net:27017']
[Server closed connection. calling ismaster on 'c.mongodb.net:27017']
I however, can connect using MongoChef
Switching any localhost references to 127.0.0.1 helped me. There is a difference between localhost and 127.0.0.1
See: localhost vs. 127.0.0.1
MongoDB can be set to run on a UNIX socket or TCP/IP
If all else fails, what I've found that works most consistently across all situations is the following:
In your hosts file, make sure you have a name assigned to the IP address you want to use (other than 127.0.0.1).
192.168.0.101 coolname
or
192.168.0.101 coolname.somedomain.com
In mongodb.conf:
bind_ip = 192.168.0.101
Restart Mongo
NOTE1: When accessing mongo from the command line, you now have to specify the host.
mongo --host=coolname
NOTE2: You'll also have to change any references to either localhost or 127.0.0.1 to your new name.
$client = new MongoDB\Client("mongodb://coolname:27017");
I had the same error in a docker based setup:
container1: nginx listening on port 80
container2: php-fpm listening on port 9000
container3: mongodb listening on port 27017
nginx forwarding php to php-fpm
Trying to access mongodb from php gave this error.
In the mongodb Dockerfile, the culprit was:
CMD ["mongod", "--bind_ip", "127.0.0.1"]
Needed to change it to:
CMD ["mongod", "--bind_ip", "0.0.0.0"]
And the error went away. Hope this helps somebody.
The IP address of your home network may have changed, which would lead to MongoDB locking you out.
I solved this problem for myself by going to MongoDB Atlas and changing which IP address is allowed to connect to my data. Originally, I'd set it up to only allow connections from my home network. But my home network IP address changed, and I started getting the same error message as you.
To check if this is the same issue with you, go to MongoDB Atlas, go into your project, and click "Network Access" on the left hand side of the screen. That's where you're able to update your IP address. It shows you what IP address(es) it's allowing in. To find out what your current IP address is, go to whatismyipaddress.com and update MongoDB if it's different.
In my case, I am temporarily coding PHP from Windows7 against MongoDB on my VPS running Linux Debian 9. The PHP will be eventually running in the same Linux box to provide an API to the MongoDB data.
BTW, it does not appear this local composer install is doing me any good, it's pure ugliness. My PHP after the fix below works without the require line require_once 'C:\Users\<Windows User Name>\vendor\autoload.php'.
My fix is different than the accepted answer which to me did not make sense.
I did not have to touch any hosts file
So edit your /etc/mongod.conf with your target machine's IP and restart with sudo systemctl restart mongod that's it
I don't know what to blame
PHP and MongoDB sites for the terrible documentation skimpy and incomplete PHP examples, or...
MongoDB installation on Linux failing to mention this bindIP.
My startup experience with MongoDB is so far very negative given all the changes that have occurred nothing matches what I expected from the videos I watched. I can't seem to find any that reflect what I am going thru like
$DB_CONNECTION_STRING="mongodb://user:password#164.152.09.84:27017"
$m = new MongoDB\Driver\Manager( $DB_CONNECTION_STRING )
instead of
$m = new MongoClient()
Hope this helps someone
PS. Always say NO to semicolons, camelCAsE and anything case-sensitive... absurdity at its best.

Vagrant not working with localhost extension on Chrome

I have a 2015 mac with macOs Sierra.
After too many problems with apache and php, I've decided to run Vagrant.
I'm running box.scotch.io for my work
Before Vagrant I configured the hosts file as follows:
127.0.0.1 devsite.localhost
127.0.0.1 sub.devsite.localhost
Remember I can't change the domains and extensions because it's not my project and I have to use those in order for some redirects and API's to work.
After Vagrant I changed it to:
192.168.33.10 devsite.localhost
192.168.33.10 sub.devsite.localhost
After editing the conf files inside vagrant, it worked fine. BUT not on chrome. I've tested in safari and firefox and it works fine.
For some reason, on Chrome those two were still showing me apache2 files.
So I've went and deleted the conf files from my local apache (for some reason). The only thing that changed was that now it shows me 403 forbidden (so still apache). I've tried shutting down apache. Now it shows me "This site can't be reached"
I've pinged them and it showed the correct IP (vagrant IP).
I've flushed the DNS (from terminal and from chrome) - still doesn't work.
I tried restarting chrome - nope. I tried restarting the laptop - nope.
So I thought that chrome dooesn't reload the hosts file, so I changed it from .localhost to .localhost2 or .local . Now it shows me the 404 from vagrant.
The weird part -> Everything i put with .localhost as extension doesn't work on Chrome... a.b.c.localhost will not work.
If I start apache, a.b.c.localhost will show me 403 forbidden from apache, even though it's not in the hosts file.
Note that in firefox and safari it works fine. But I really need chrome and the .localhost extension
I've already lost almost 2 days on this issue and I can't afford to lose another one
Find related information here: https://bugs.chromium.org/p/chromium/issues/detail?id=489973
In short: this seem to be a known Chrome feature: /etc/hosts is ignored for resolution of host names ending with .localhost, as OS X specific security mitigation. Comment 22 indicates a workaround: add 127.0.0.1 localhost. into /etc/hosts (and note the trailing dot after "localhost.").
For host management you can use a special plugin https://github.com/devopsgroup-io/vagrant-hostmanager AFAIR they resolved Chrome + MacOS issue

Why won't Apache Server start in MAMP?

I'm trying to view php files locally on my mac.
I'm running Yosemite.
I have MAMP installed on my computer. When I press start the MySQL server starts but Apache doesn't. An error message appears saying 'Error. Apache couldn't be started. Please check your MAMP installation'
I've gone through the internet typing stuff into terminal and changing 'envvars' to '_envvars' but nothing works.
I reinstalled OSX and that worked but when I shut down the computer the problem occurs again.
Can anyone help?
Thanks
Check if you changed the Document Root Location or Renamed it. At least this was my mistake.
MAMP > Preferences > Web Server > Document Root
I didn't get it working with port 8000 or the default 8888, but did get it working with port 80 per the suggestion here:
http://forums.macrumors.com/showthread.php?t=1744944
That didn't work after all, but it didn't error out. However I manually ran the following at the command line (because log file was empty):
sudo /Applications/MAMP/Library/bin/apachectl start
Only to find that after upgrading I was missing the mod_example.so
httpd: Syntax error on line 83 of /Applications/MAMP/conf/apache/httpd.conf: Cannot load /Applications/MAMP/Library/modules/mod_example.so into server: dlopen(/Applications/MAMP/Library/modules/mod_example.so, 10): image not found
Copied it from my old install and I was good to go.
If you try to start the server from the terminal, likely that will tell you what is wrong e.g.
sudo /Applications/MAMP/bin/startApache.sh
Password:
(48) Address already in use: make_sock: could not bind to address [::]:8888
(48) Address already in use: make_sock: could not bind to address 0.0.0.0:8888
no listening sockets available, shutting down
Unable to open logs
What you can do in this case, I was inadvertently running a Blockstack browser out of 8888, so changing MAMP to 8887 allowed it to start. [Your mistake might be different.]
Had the same problem, nothing in the logs. After trying the_dillio's suggestion:
sudo /Applications/MAMP/Library/bin/apachectl start
I got an error that pointed back to my vhosts file. It turns out I had an extra /VirtualHost tag. Removed it and it started working again.
i've solved this issue using this command in the terminal :
sudo apachectl stop
I think I've found the solution.
It was the wrong port. I altered the .conf file in the Apache folder. I changed all instances of port 8888 to 8000. When I run MAMP now it all seems to work fine.
Thanks for your help
Also be aware that if you by any chance deleted the folder that was set as Document Root the last time you were using MAMP, you will get this error. Simply open MAMP again, change Document Root to a location that does exist and start the servers.
I received the same error but interestingly it was caused simply because I renamed the root folder and didn't realize it. Sounds like you have a different issue but for anyone else who gets this error message, make sure you haven't renamed the root!
Absolutely bizarre behavior for MAMP PRO (paid license too btw...)
In my case I had to change the location of the log file in order to get it to work...
Click on Mysql icon then the little folder to the right of the path and try changing it to something else.
For MAMP :
You can open the terminal and write:
ps aux | grep mysql
lsof -i
killall -9 mysqld
I hope is good for you!
Bye
I had this experience when upgrading to V4. It tried to used the files from my previous installation and it just never worked. The workaround was to RENAME the original MAMP installation to something different than "MAMP", install brand new version and then copy files you may need like VHOST configs and DATABASES. After all this it worked just fine.
My Apache server problem arose after I enabled SSL. So if this is your case, check your https-ssl.conf file (Applications -> Mamp -> conf -> apache -> extra). The Document Root under the Virtual Host settings had a different file path for htdocs than where it was actually located (easily overlooked). I changed this to "/Applications/MAMP/htdocs" and problem solved. Perhaps also check Document Root in your https.conf file (Applications -> Mamp -> conf -> apache) to see if it has the correct file path to htdocs too.
These are the steps I used to solve this issue.
Checking vcredist that are required and installing them. to check which are the missing vcredist I used a tool called "check_vcredist" from wamp.
I also installed latest Microsoft Visual C++ Redistributable x64.
Doing this steps solved my issue of Apache server not running

Mac OS 10.8: apache exiting with code 1

I've been reading about this issue and have tried many things, but none seem to work for me. After being very frustrated with XAMPP, I'm trying to setup a development environment locally using the apache that's already installed (along with php and mySQL).
Whenever I do:
sudo apachectl start
Nothing happens, and the console displays:
8/23/13 3:21:08.262 PM com.apple.launchd[1]: (org.apache.httpd[1086]) Exited with code: 1
8/23/13 3:21:08.262 PM com.apple.launchd[1]: (org.apache.httpd) Throttling respawn: Will start in 10 seconds
I've tried doing the suggestion that is most common, which seems to be to make a directory for the error log, and chmod 777 it.
If I do:
sudo apachectl -t
I get:
Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist
Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist
httpd: Could not reliably determine the server's fully qualified domain name, using 10.5.120.124 for ServerName
Syntax OK
I see that my IP address is in the 3rd line there, and I'm thinking maybe that's the source of the issue? If anyone can give me any advice as to what might help, that'd be great.
Thanks!
Just to follow up on this for anyone else that might be encountering this issue, it ended up being something amiss in my Virtual Hosts file. After combing through that, there were some syntax issues going on that was, in turn, causing this issue to happen.

XAMPP - local host problems

I have picked up some possible answers to my problem here, but none have so far worked.
I have installed XAMPP but get the dreaded HTTP 404 error on both IE and Firefox when asking for 'http://localhost/'. I work with Dreamweaver but cannot get the testing server (XAMPP) to work, although I can connect to the linux/apache remote server.
Skype has been uninstalled. Therefore XAMPP is running on port 80 by itself.
XAMPP says Apache and Mysql have 'started'.
Is there someone that could please help me?
If some other software is using the same port as XAMPP, so please change it. Like Skype is using 80 or 443 change it and then run xampp.
Thanks Colin and nc3b,
In \xampp\apache\logs\error.log is this message:
httpd.exe: Syntax error on line 35 of
C:/Program Files
(x86)/xampp/apache/conf/httpd.conf:
ServerRoot must be a valid directory
Line 35 says: ServerRoot "/xampp/apache"
Typed this C:\Program Files\xampp\apache into browswer which pointed me to apache_installservice which loaded (url c:/windows/system32/cmd.exe) saying apache isn't installed, went through a couple of yes/no questions on the dos type browser page - this resulted in the system saying several files could not be installed (chmod reasons).
When installing XAMPP, instead of going with the default drive of c:/ I instructed that XAMPP be installed in c:/programfiles - Duhhhh maybe this is my problem?
Will try reinstalling directly on the c:/ drive.
Thanks for pointing me in the direction..... will let you know the outcome....
Close Skype if you have it open... just a shot in the dark. If it fixes your issue, then change the port number it uses, I had an issue a while back where Skype prevented XAMPP from running.
I had exactly the same problem recently after installing node.js on windows 8, my wordpress admin stopped working. Here's what fixed the problem: I opened command line as administrator and type NET STOP HTTP. (this stopped the default windows web server which use port 80).
After doing this I'm able to access my Wordpress administrator site which use port 80 by default.

Resources