cannot resolve localhost [closed] - macos

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
When I do a ping on localhost, I get "ping: cannot resolve localhost: Unknown host". A ping on 127.0.0.1 does work. So I checked my hosts file and everything looks so far correctly:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
#Added by XAMPP Control
127.0.0.1 mkn.local
#Added by XAMPP Control
127.0.0.1 mkn.local
I also did a "dscacheutil -flushcache" but I still can't ping "localhost". The problem is that right now I can't debug anymore in eclipse because eclipse contacts localhost (and right now localhost cannot be resolved to 127.0.0.1).
Many thanks for any help in advance!
P.S. I have OSX 10.7.2 (Lion OS)

I restored the hosts file from an older backup. I don't see any differences between my backuped hosts file and the current file. However, it works now .... magic

Related

Setup PPTP to access home network transparently [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Setup PPTP to access home network transparently
I have Raspberry Pi box connected to home WiFi-router and running pptpd. The local addresses is 192.168.1.32 (eth0) and 192.168.2.1 (ppp0) and local name raspberry.local.
I have iMac connected to the same router with local IP 192.168.1.27 and local name imac.local
I have Macbook somewhere in the Internet connected to Raspberry’s PPTP with 192.168.2.10 on ppp0
This picture shows more clearly.
pptpd configuration
PPTP on Raspberry was installed from this simple script.
/etc/pptpd.conf
option /etc/ppp/options.pptpd
logwtmp
localip 192.168.2.1
remoteip 192.168.2.10-100
/etc/ppp/options.pptpd
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd
/etc/rc.local
…
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -I INPUT -p tcp --dport 1723 -j ACCEPT
iptables -I INPUT --protocol 47 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -d 0.0.0.0/0 -o eth0 -j MASQUERADE
iptables -I FORWARD -s 192.168.2.0/24 -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j TCPMSS --set-mss 1356
…
Curent connectivity
Macbook
can connect to home PPTP and connect to Internet through the home router
can connect to iMac and Raspberry via local IPs 192.168.1.27 and 192.168.1.32
can NOT resolve raspberry.local and imac.local
Raspberry
can connect to iMac and Macbook via local IPs 192.168.1.27 and 192.168.2.10
can resolve imac.local
can NOT resolve macbook.local
iMac
can connect to Raspberry via local IP 192.168.1.32
can resolve raspberry.local
can NOT connect to Macbook via local IP 192.168.2.10 (upd: Solved by adding static route to the router)
can NOT resolve macbook.local
The goal
The goal is to connect and resolve local names from any to any. But I have no idea how to configure this: iptables, avahi, netatalk or somewhere else?
These are 2 separate goals and you have to solve them separately.
For resolution to work: You need to set up a DNS server somewhere (iMac?) and designate it as a resolver in all your devices/computers.
Or go with an easier setup, put the name <-> ip address relations into the /etc/hosts file on all your devices/computers
For connectivity: Your iMac simply "does not know" (i.e. no route) how to connect to what is behind the raspberry. However, it DOES work vice-verse since your raspberry is doing NAT for the macbook.
Do you have access to your WiFi router's routing table? If yes, you need to add a route to the PPP network (192.168.2.0/25) via raspberry's external IP address (192.168.1.32).
The exact command or configuration steps, however, depend on the vendor/model of your WiFi router, so I cannot give you a more detailed answer here.

Access website hosted on local vagrant vm [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am trying to make a local dev environment so I can work on my site matthewfedak.co.uk.
I am using vagrant and virtual box.
Here is my vagrant file:
Vagrant.configure("2") do |config|
config.vm.box = "lucid32"
config.vm.provision :shell, :path => "localhost.sh"
config.vm.network :forwarded_port, host:4567, guest: 80
config.vm.network :forwarded_port, host: 3306, guest: 3306
config.vm.synced_folder "/Users/mfedak/sites", "/var/www/vhosts", :owner => "www-data", :group => "www-data"
end
Here is my /etc/hosts file:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
#127.0.0.1 localhost
#255.255.255.255 broadcasthost
#::1 localhost
#fe80::1%lo0 localhost
127.0.0.1:4567 matthewfedak.co.uk
127.0.0.1:4567 www.matthewfedak.co.uk
Here is my vhost for the site in /etc/apache2/sites-enabled/matthewfedak.co.uk
vagrant#lucid32:~$ sudo vim /etc/apache2/sites-enabled/matthewfedak.co.uk
<VirtualHost *:80>
ServerAdmin info#matthewfedak.co.uk
ServerName matthewfedak.co.uk
ServerAlias www.matthewfedak.co.uk
DocumentRoot /var/www/vhosts/matthewfedak.co.uk/httpdocs/
ErrorLog /var/www/vhosts/matthewfedak.co.uk/logs/error.log
CustomLog /var/www/vhosts/matthewfedak.co.uk/logs/access.log combined
</VirtualHost>
It sounds simple but I am getting bored of toying with this now. I have setup lots of Ubuntu servers before so don't think that its to with that, just to do with getting the host / remote to communicate.
By default Vagrant uses NAT mode for networking, which requires a lot of port mappings if you are testing a full stack. What's more, due to the limitation of VirtualBox's NAT mode:
Forwarding host ports < 1024 impossible:
On Unix-based hosts (e.g. Linux, Solaris, Mac OS X) it is not possible to bind to ports below 1024 from applications that are not run by root. As a result, if you try to configure such a port forwarding, the VM will refuse to start.
That's why you use port 4567 on host, right?
Now, Root cause is in your /etc/hosts
127.0.0.1:4567 matthewfedak.co.uk
127.0.0.1:4567 www.matthewfedak.co.uk
The hosts file is a simple text file that associates IP addresses with hostnames, one line per IP address. It does NOT work with port numbers.
To work around, consider using bridged mode or vagrant's private network so that you can access the guest using an IP address instead of using host's loopback.

Not able to run commands on Hbase shell

I keep getting INFO ipc.HBaseRPC: Problem connecting to server: /129.10.193.117:49176 when I try to create or disable tables in Hbase. I have googled this error and found couple of answers. All of them say something like "Default installation added a line in /etc/hosts which linked to machine hostname with the IP 127.0.1.1."
Here is my etc/host file
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
Also my conf/regionservers is pointing to localhost. Does anyone know how to fix this ? After shutting down hbase & Hadoop and then restarting my system, I do not get this error. Not sure why.
Are you hadoop configurations also pointing to localhost ?

How can I eliminate slow resolving/loading of localhost/virtualhost (a 2-3 second lag) on Mac OS X Lion?

Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly.
If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached.
As can be seen below I am not using the .local TLD.
My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost
My /etc/hosts:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 myproject.dev
::1 myproject.dev
fe80::1%lo0 myproject.dev
My virtual host set-up in username.conf:
NameVirtualHost *:80
<Directory "/Users/myusername/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/myusername/Dropbox/dev_envs/
</VirtualHost>
<VirtualHost *:80>
ServerName myproject.dev
DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname
</VirtualHost>
I had the exact same problem and it was driving me crazy!
Put all your hosts file entries for localhost into one line like so:
127.0.0.1 localhost myproject.dev myotherproject.dev
::1 localhost
fe80::1%lo0 localhost
Worked like a charm for me. Seems like a bug in Lion.
There's another issue 10.7.* to 10.8.4 for sites ending in .local which causes five second lookups. Details and solution courtesy Bram Van Damme’s blog post found here.
“By default, any hostname ending in .local is treated as a Bonjour host rather than by querying the DNS server entries in Network preferences.”
“To fix this problem (without having to rename each vhost) you need to add IPv6 entries for each of your vhosts in your /etc/hosts file:”
::1 mysite.local
fe80::1%lo0 mysite.local
127.0.0.1 mysite.local
I had the same problem, also on Lion.
Strangely, my solution was the opposite of Jeremy's. I had a whole bunch of someproject.dev entries on one line in /etc/hosts. Loading a site on any of them the first time took forever, like a minute or so. If I used it again within 5 seconds or so it was very fast, but much longer and it would again take a minute. I had suspected all sorts of things, mysql connections, Ruby versions, Rails bugs, Apache, Phusion Passenger. Until I finally looked at the Console and realized that DNS lookups were being attempted.
So, I put all of them on seperate lines:
127.0.0.1 localhost
127.0.0.1 myproject.dev
127.0.0.1 myotherproject.dev
And suddenly everything was snappy again. Same on both my machines.
Specifying same host for IPv6 ::1 helped me.
127.0.0.1 something.local.mydomain.org
::1 something.local.mydomain.org
Make sure to put the IP v6 entries not in the line with localhost
::1 localhost
the IP v6 entries go in a separate line
fe80::1%lo0 here and_here
It is sometimes really fast now, but there are rare exceptions where the old lags come back. They might however be based on other reasons.
On OSX El Capitan what worked for me was making a duplicate IPv6 entry right above the IPv4 entry like so
fe80::1%lo0 demo.test.dev
127.0.0.1 demo.test.dev
Ensuring that the host names are defined at the beginning of the file made the difference for me.
By default the line 127.0.0.1 localhost is already at the beginning, just add your entries on the same line.
I had the same problem and found it to be caused by enabling IPv6 on my LAN, but not having IPv6 configured correctly between my network and my ISP. Apparently the IPv6 DNS-server takes precedence over IPv4 DNS when the client is given both. It took a couple of seconds (on every attempt) for the client to find that the IPv6 DNS was unreachable or missing, and then falling back to IPv4 DNS.
Note: I am using Windows and XAMPP, however while researching the problem many people have had the same issue on Windows and Mac. Answer for reference for anyone finding this question as I have spent hours trying to find a solution that works for me:
I have tried many solutions for the same problem including putting all of the hosts on one line, removing redundant hosts and virtualhosts, and also including the IPv6 lines - none of these alone were successful.
The only solution which has so far appeared to work for me is a combination of all of the solutions:
Changing the domain I am using from mysite.local to mysite.dev. Inspired by #Cleverlemming's answer.
Including the IPv6 lines.
Removing redundant virtualhosts and hosts (I commented them out).
In my hosts file my hosts are currently on separate lines and so far the issue seems to be fixed.
Good luck to anyone attempting to solve this issue and if anyone has any information to add please do so - this seems to be an issue affected a lot of people with no single known cause or solution.
I had this same problem and finally realized I had the same host entry twice on the same line:
e.g.
127.0.0.1 localhost host1 host2 host3 host4 host5 host1 host6
I removed the second instance of the same host (in the example above - host1) - and things immediately sped up.
Felt a little silly when I discovered this, but when you've got 10 long host names on the same line and you're frequently adding / removing, it can be eaisly overlooked.
The trick that did it for me was adding
127.0.0.1 locahost
on the first line of the host file.
From all my virtual hosts, only the ones using a database were slow. I believe it's because the process of looking up "localhost" for the database connection slowed things down, since I only added the addresses for my virtual hosts and not "localhost" as well. Now it's all snappy again. :)
I've run into this a bunch, too. I have a bunch of vhosts defined on two lines, one for IPv4 and one for IPv6. Moving the host I was trying to resolve to be first in the list sped it up.
127.0.0.1 faster.example.dev host1.example.dev host2.example.dev host3.example.dev host4.example.dev host5.example.dev host6.example.dev
::1 faster.example.dev host1.example.dev host2.example.dev host3.example.dev host4.example.dev host5.example.dev host6.example.dev
A dumb issue that led me to waste some considerable time: after applying #Cleverlemming's answer, I figured out that there were duplicated entries on the hosts file. Something like:
::1 site1.local site2.local site1.local site3.local site4.local
fe80::1%lo0 site1.local site2.local site1.local site3.local site4.local
127.0.0.1 site1.local site2.local site1.local site3.local site4.local
Then IP resolving for site3.local and site4.local takes these 5-seconds of death.
This helped me: Apache HTTP localhost randomly taking 5 seconds on macOS Monterey but fast on HTTPS
Turn off Keep Alive by adding:
KeepAlive Off
To your http.conf

setting archlinux hostname (Amazon EC2) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Setting the hostname on an archlinux machine is relatively trivial according to this - https://wiki.archlinux.org/index.php/HOSTNAME#Set_the_hostname
So on my /etc/rc.conf, I have
LOCALE="en_US.UTF-8"
TIMEZONE="UTC"
MOD_AUTOLOAD="no"
USECOLOR="yes"
USELVM="no"
DAEMONS=(syslog-ng sshd crond ec2 httpd)
HOSTNAME="archlinux"
And corresponding on my /etc/hosts, I have
127.0.0.1 archlinux.domain.org localhost.localdomain localhost archlinux
Following the docs to the tee.
But unfortunately, restarting httpd fails with the error in the error_log:
[Tue Sep 06 04:26:06 2011] [alert] (EAI 2)Name or service not known: mod_unique_id: unable to find IPv4 address of "ip-10-130-57-114"
Configuration Failed
And yes, I am aware that from https://wiki.archlinux.org/index.php/Apache#Apache - it is possible to solve this problem by commenting
LoadModule unique_id_module modules/mod_unique_id.so
But I would much prefer to solve this problem by keeping this module loaded and resolving it by making sure that I have set my hostname correctly in /etc/hosts instead.
It looks like Apache is using "ip-10-130-57-114" hostname instead of "archlinux". Have you tried adding this entry into your /etc/hosts file?
10.130.57.114 ip-10-130-57-114
* I am guessing 10.130.57.114 is the internal host ip address of you instance.
What does hostname -f say?
What is reverse DNS name for your IP?
Can you try to set host name to archlinux.<valid_domain> instead of archlinux so it is globally resolved?

Resources