Apache IP address working but localhost does not - linux

I downloaded Apache2 and it is currently running. I typed in my IP address and it brings me to the "It Works!" page, however when I type in localhost or 127.0.0.1 I receive an error. Can someone tell me whats up?

check 127.0.0.1 able to ping or not with same machine.
check /etc/hosts file having 127.0.0.1 entry or not?
check in apache configuration file Listen 0.0.0.0:80 or not?

Related

Linux process/component sending frequent DNS queries to resolve the local hostname (but shouldn't)

I'm not a networking guru so could use some help. I am running a RHEL7 (Red Hat Enterprise Linux) VM (Virtual Machine) where some component on the OS is sending frequent DNS queries to resolve it's own local hostname to our main DNS server (which shouldn't be happening because the DNS server won't know anything about its address). Can anyone provide guidance as to how I can find out what component/service/process this is? It's filling our logs with 19k records over just hours and I need to find a way to fix this.
The hostname for the RHEL VM is spe1.2v29999999.dev.local , there is a static IP on this VM and it is 10.70.49.61. The /etc/hosts looks like:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost4 localhost4.localdomain4
I suspected it might be a java jar we have running on the VM, but I stopped it via systemctl stop MyJavaJar but after running a tcp dump via tcpdump -i any udp port 53, I could still see the queries happening.
Here are some examples from different days/times in the logs (both A and TXT records):
2020-05-05T13:53:50.189178+00:00 dns.green.blue.mycompany.com 127.0.0.1 <daemon.info> dnsmasq[20886]: 739 10.70.49.61/65078 query[A] spe1.2v29999999.dev.local from 10.70.49.61
2020-05-07T00:01:39.934899+00:00 dns.green.blue.mycompany.com 127.0.0.1 <daemon.info> dnsmasq[8615]: 27827 10.70.49.61/57348 reply spe1.2v29999999.dev.local is NXDOMAIN
2020-05-11T00:01:20.674688+00:00 dns.green.blue.mycompany.com 127.0.0.1 <daemon.info> dnsmasq[8615]: 130345 10.70.49.61/53321 query[TXT] bootstrap.spe1.2v29999999.dev.local from 10.70.49.61
Would making any changes to /etc/hostname, /etc/sysconfig, /var/named .zone files, /var/named.conf or /etc/named help? Can I do more with tcpdump? Thanks
Put:
127.0.0.1 spe1.2v29999999.dev.local
in /etc/hosts. This is done by default on many distros.

IIS can't access hostname but localhost

I don't know why do my IIS can't connect / bind the hostname. It works good if I browse with the localhost (http://localhost:23152), but it doesn't work if i browse with the hostname (http://test.company.com:23152). I already registered the hostname in hosts file (C:/windows/system32/drivers/etc/hosts)
It works good without hostname
It doesn't work with hostname
Here's when I try to ping the hostname (as you can see, the IP Address doesn't show the 127.0.0.1)
Is there something I'm missing?
Any help will be appreciated, Thanks :)

How to configure apache in local development in rails

I am trying setup a loacl domain on my pc for that I have apache server install I want to open my rails s inside this abcd.com instead of 127.0.0.1:3000. In my host I have changed host file like this:
127.0.0.1 localhost
127.0.0.1 abcd.com
But when I am trying to open abcd.com with this command I am getting this message:
Address already in use - bind(2) for "127.0.0.1" port 80 (Errno::EADDRINUSE)
When I stop apache it works on localhost any help
You need to write all hostnames behind the ip like this :
127.0.0.1 localhost abcd.com

URL with hostname does not work but works with IP address

I am working on RHEL 6.3, the IP address of this server is 172.xxx.xxx.xx and hostname is build01.xxx.com
I have a DNS entries of client server, I have configured that in /etc/sysconfig/network-scripts/ifcfg-eth0 and in /etc/resolv.conf
[root#build01 ~]# cat /etc/resolv.conf
search 100.xxx.x
nameserver 203.xxx.xxx.xxx ##Primary DNS
nameserver 203.xxx.xxx.xxx ###Secondary DNS
[root#build01 etc]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
172.xxx .xxx.xx build01.xxx.com build01
[root#build01 ~]# hostname
build01.xxxx.com
My issue is when I hit the URL with hostname(buil01.xxx.in) it does not work, but it works with IP (172.xxx.xxx.xx)
This is the error which i get in browser if I type hostname
Host Not Found
**DNS error (the host name of the page you are looking for does not exist) or Server did not accept the connection.
Please check that the host name has been spelled correctly.**
Internet works in this machine only issue is with hostname
Please help me what I am missing to configure
Thanks
Roopa
The search line in resolv.conf should list the local domain. So change:
search 100.xxx.x
to:
search xxx.com
Actually you should also change search to domain. For more information have a look at man resolv.conf.

host doing unnecessary dns lookup for localhost

I have a centOS system(embedded and has very binaries) with the following /etc/hosts.
$cat /etc/hosts
127.0.0.1 localhost localhost
Also the host is assigned a DNS server which returns some invalid IP for the domain name lookup of localhost. But I cannot avoid a connection to this DNS due to some network restrictions.
My question is, when I already have a valid /etc/hosts file why is the system querying the DNS for localhost? And how can I stop that?
Any help would be greatly appreciated.
Check that you have files listed before dns for the hosts entry in /etc/nsswitch.conf.
[me#home]$ grep "^hosts" /etc/nsswitch.conf
hosts: files dns
If dns comes first, then your system will always query DNS to resolve hostnames before falling back to /etc/hosts.

Resources