Search code examples
macosapacheserverlocalhostmamp

MAC, MAMP, 127.0.0.1 connection refused, localhost fine


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


Solution

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