MAC, MAMP, 127.0.0.1 connection refused, localhost fine - macos

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..

Related

XAMPP receives "Connection refused" when curling other localhosts

I've a Reactjs app (NodeJS) running on localhost:3000 as well as a local blockchain node (Hardhat) running on localhost:8545.
There's no issues with those two communicating with each other, but I also have a XAMPP server running locally on localhost:8080 with a php app that returns some values.
I can reach all these localhosts fine through the browser.
But I need the php to communicate with my blockchain node. But the connection keeps getting refused when Xampp tries to create the connection to the node.
I even tried a basic curl from Xampp's terminal, and Xampp can't reach the other localhosts at all (tried both http://localhost:port and http://127.0.0.1:port). For instance if I just wanted to curl my react app (html) from Xampp's terminal like this...
curl http://localhost:3000/ -v
I get this...
* Trying ::1...
* TCP_NODELAY set
* connect to ::1 port 3000 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* connect to 127.0.0.1 port 3000 failed: Connection refused
* Failed to connect to localhost port 3000: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 3000: Connection refused
Yes, I can curl things like google.com fine from within Xampp's terminal with no issues. It's just my localhosts. Yes, I have enabled curling in php. Yes, I can curl my react app (html) just fine from a separate terminal window. I'm on MacOS 12.1.
Thanks in advance for any help!!
Edit: I did some research, and I believe the issue is that the Xampp virtual machine can't reach my localhost. I've tried resolving this at the host file level to redirect a domain name to 127.0.0.1, but that doesn't work either. I'm still stuck, but wanted to put an update in case this info is helpful.
Last edit: I gave up.

Connect localhost from host virtualbox

I have a Laravel app in Virtualbox in the localhost aka 127.0.0.1:8000 and I want to connect from my host to the server.
Also, it will be great that anyone with the same network can connect to my localhost.
How can this be done?
You can pass the host while running the php artisan serve command.
For example, your network IP is 192.168.1.2
Then run the command like this
php artisan serve --host=192.168.1.2
Hope this will work for you.

Curl Localhost Issue in Mac Terminal

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.

Connection refused for 127.0.0.1 on OSX Yosemite

I'm on a really strange situation.
I'm using MAMP and I can't access to my working directory from the 127.0.0.1.
When I'm using localhost instead of 127.0.0.1 it works because the localhost is redirected to the ::1 ipv6 address.
So, I can access to my local server only via ipv6.
I've tried to start a little server with Python and it doesn't work ( it works fine on my personal laptop using OSX El Captain ).
When I try with an other port than 80 it works but I need to use this port ..
It's not a conflict, when I'm running the Python server he is the only one to listen the port 80
Do you have an idea about this trouble ?
Why I can use the ipv6 local address only ?

localhost on MacOSX connection refused

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

Resources