I'm getting the error
curl: (7) Failed to connect to localhost port 80: Connection refused
when I execute the command
curl localhost
in Mac terminal.
My /etc/hosts file content
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
How can I fix this?
Start a webserver that listens on port 80.
Related
My mac won't connect to localhost, I've tried with Safari and Mozilla, so it's not the browser, I tried other solutions I found on the internet, I ping 127.0.0.1 and it works correctly, if I run dscacheutil -q host -a name localhost I get the following:
name: localhost
ipv6_address: ::1
name: localhost
ip_address: 127.0.0.1
If I run apachectl configtest I get Syntax OK.
I've also read that my /etc/hosts might have been corrupted, this is how it looks like:
##
# 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
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
I have no idea what else to try
EDIT: I'm trying to run an application (Hortonworks Sandbox) from a virtual machine (VirtualBox) in mac, I was advised to try port forwarding but this is what I see when I check the port forwarding in VirtualBox, seems like everything is in order:
I also tried to run Vagrant from VirtualBox and Mac couldn't connect to the localhost server when needed
I'm using Mac 10.13.6. I just installed elasticsearch via homebrew and launched it ...
brew services start elasticsearch
Service `elasticsearch` already started, use `brew services restart elasticsearch` to restart.
In my /usr/local/etc/elasticsearch/elasticsearch.yml configuration file, I have
http.port: 9200
However, when I attempt to see if that port is available, I get a connection refused ...
localhost:tmp davea$ telnet localhost 9200
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
What port is elasticsearch getting launched on and how can I change that?
That may be the problem of Mac firewall? Edit elasticsearch.yml file in elasticsearch/config folder. Change the localhost to 127.0.0.1 to take a try?
network.host: 127.0.0.1
#
# Set a custom port for HTTP:
#
http.port: 9200
#
Why can I not successfully connect to jetty?
I have the latest version of jetty 9.x running. I have the jetty_base folder setup and when I drop war files into the folder I see them get expanded into the /tmp folder.
lsof -i :8080
java 26488 jetty 85u IPv6 400595 0t0 TCPlocalhost.localdomain:webcache (LISTEN)
curl 'http://localhost:8080' curl: (7) Failed connect to
localhost:8080; Connection refused
curl http://127.0.0.1:8080 curl: (7) Failed connect to 127.0.0.1:8080;
Connection refused
From the below output of lsof -i:8080
java 26488 jetty 85u IPv6 400595 0t0
TCPlocalhost.localdomain:webcache (LISTEN)
It seems jetty is using ipv6 rather ipv4.
For ipv6, use ::1 as your loopback address. For ipv4, it is 127.0.0.1.
Changes you can make for localhost to work :
If you wish to set localhost to work for both ipv6 and ipv4 you can make below changes to /etc/hosts file.
127.0.0.1 localhost
# ... and below
::1 localhost ipv6-localhost ipv6-loopback
As always, you can test the connectivity using ping6 ::1 for an ipv6 ip and ping 127.0.0.1 for ipv4.
Give a try!
As title says, I can access localhost fine but my app needs a callback from twitter through 127.0.0.1:8000 and 127.0.0.1:8000 is getting "connection refused"
EDIT: This looks to be an IPv6 conflict, I can access my local server through (Apache Port) http://127.0.0.1:8888/
EDITEDIT: It appears if I serve an angular app on port 9000 I can reach it with 127.0.0.1:9000 in my browser fine, however if I run php artisan serve --port=9000 then then I still get a connection refused error.
So my issue has been refined to: How can I get php artisan serve (for laravel app) to work with http://127.0.0.1:8000/
Lewiss-MBP:stripe2 Lewis$ php artisan serve
Laravel development server started on http://localhost:8000/
The meat:
OSX YOSOMITE 10.10.5
MAMP (non pro) is set to Apache not NGINX
etc/hosts : file -b /etc/hosts === ASCII English text
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
Lewiss-MBP:applications Lewis$ telnet -6 ::1 8000 </dev/null
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
Lewiss-MBP:applications Lewis$ telnet -4 127.0.0.1 8000 </dev/null
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
l;dr; SOLVED : after a LOT of trawling, if I run php artisan serve --host 0.0.0.0 my app works fine, as does twitter app callbacks to 127.0.0.1
The issue must be in how Artisan listens..
I've had my app running on localhost port 80 via nginx on my mac for quite awhile. Recently I did some software updates and was trying to run other apps on different ports and now I can't run my first app on localhost:80.
I've very confused on where to start but think this is a firewall issue based on the following:
Tims-MacBook-Pro-2:html TimPeterson$ telnet localhost 80
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
pointing the browser to http://localhost gives this Oops! Google Chrome could not connect to localhost
thoughts?
you may want to run
apachectl configtest
first.
My problem was specific, but might help another user. On Mac OS go to system preferences/sharing and check your computer name/localhost name (click edit to see the localhost name). My computer was reset by Apple in a non-English speaking country. They stuck some of their language in my computer name (great idea!) and it broke the Cisco login to localhost
What worked for me was uncommenting the following line in my /etc/hosts file:
::1 localhost