localhost refused to connect

Issues related to configuring your network
wp.rauchholz
Posts: 63
Joined: 2016/11/20 11:58:45

localhost refused to connect

Postby wp.rauchholz » 2017/11/24 16:15:15

I setup a LAMP server. It works mostly fine, but when entering localhost as address I get the message that localhost refused to connect.
I checked error_log, access_log and also messages, but there is no trace as to why localhost cannot access. I need localhost access for a new service I want to install on my home server.
Entering my domain name and server's IP address works fine. I can also ping localhost.

I set in /etc/hosts
server IP address FQDN hostname
server IP address localhost
127.0.0.1 localhost localhost.localdomain

/etc/resolv.conf
search domain name
nameserver 127.0.0.1

grep ^hosts /etc/nsswitch.conf gives : hosts: files dns myhostname
I tried this in all bowers with same result; chrome, firefox, explorer
What is wrong?

Thanks for your help
Last edited by wp.rauchholz on 2017/11/24 16:45:37, edited 1 time in total.

wp.rauchholz
Posts: 63
Joined: 2016/11/20 11:58:45

Re: localhost refused to connect

Postby wp.rauchholz » 2017/11/24 16:43:59

I just tried this. localhost can connect to apach port 80

localhost can connect to apache on port 80.

[root@home ~]# curl -v localhost

About to connect() to localhost port 80 (#0)
Trying 127.0.0.1...
Connected to localhost (127.0.0.1) port 80 (#0)
GET / HTTP/1.1
User-Agent: curl/7.29.0
Host: localhost
Accept: /
< HTTP/1.1 200 OK
< Date: Fri, 24 Nov 2017 16:38:15 GMT
< Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_python/3.5.0- Python/2.7.5 PHP/7.1.11
< Last-Modified: Fri, 03 Feb 2017 07:00:08 GMT
< ETag: "ab-5479ad509dcff"
< Accept-Ranges: bytes
< Content-Length: 171
< Content-Type: text/html; charset=UTF-8
<

<title>Welcome to my new web server</title>
wo-lar.com Linux Home Server
Have fun * Connection #0 to host localhost left intact

User avatar
TrevorH
Forum Moderator
Posts: 22291
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: localhost refused to connect

Postby TrevorH » 2017/11/24 17:13:17

server IP address localhost


That should not be there. Only 127.0.0.1 (and ::1) should be mentioned for localhost.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

wp.rauchholz
Posts: 63
Joined: 2016/11/20 11:58:45

Re: localhost refused to connect

Postby wp.rauchholz » 2017/11/24 20:51:28

I made the change and restart network.service
/etc/hosts looks like this now
server IP FQDN hostname
127.0.0.1 localhost localhost.localdomain
::1 localhost6.localdomain6 localhost6

But localhost is still rejected. What else can it be?

This site can’t be reached

localhost refused to connect.
Did you mean http://locallhost.com/?


Thanks, Wolfgang