Mac OS local proxy, connect ECONNREFUSED ::1:3000 - macos

I have a create-react-app app running on localhost:3000 and a proxy server running on localhost:4000 that redirects some of my request to port 3000.
Requesting localhost:3000/ correctly returns index.html file,
Requesting localhost:4000/ returns connect ECONNREFUSED ::1:3000 with 502 code.
The exact same setup works properly on Ubuntu (returns index.html from localhost:4000) and Windows so I am sure proxy works fine.
Proxy is built using https://www.npmjs.com/package/http-proxy but i was unable to find any solution to this in documentation.
My question is: Does mac require changing some extra settings to allow this kind of traffic?

One solution is to edit /etc/hosts and remove ::1 localhost mapping or change it to ::1 ip6-localhost (default setting on ubuntu)

Related

Can't connect to 127.0.0.1 on High Sierra

I have set up localhost on High Sierra and have all of my web projects in the Sites directory. Everything works fine in that I can access my site using:
http://localhost/~foo/my-site
No problems here. However, I now require Cassandra for one of my projects and I am trying to connect to it on the default ports using:
127.0.0.1:9042
It doesn't work. If I go to 127.0.0.1 I get:
Forbidden
You don't have permission to access / on this server.
I can ping 127.0.0.1 though. Any ideas on how I can get localhost to work while still using Sites?

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 ?

OSX SSH tunnel from remote port to local

I've created SSH tunnels in the past, but I'm having trouble on OSX. I'm looking to take a website's port 80, and direct it to my localhost:8080. When I run this command
ssh -L 8080:<cloud_ip_address>:80 root#<cloud_ip_address> -N
I get the default apache 'it works!' page.
Why am I not getting the port 80 of the remote machine (which is running a web app)?
UPDATE
I still do not have a solution yet, but I have some more information. The page I am getting is the default page in /var/www/html but I am serving a Flask app which does not have static pages.
Because HTTP protocol contains not only the IP address, but also the hostname (the URL you type into your browser), which differs between the <cloud_hostname> and localhost. The easiest way to trick it is to create /etc/hosts (there will be some OSX alternative -- search ...) entry redirecting the hostname of your remote machine to localhost.
127.0.0.1 <cloud_hostname>
But note that in this case you will not be able to access the remote machine using the hostname!

Cannot access localhost:8080 from laravel

I have a PHP application running on homestead box. This application makes calls to another app that is running on glassfish on my localhost:8080.
When PHP application sends the request to localhost:8080, I am getting following error:
ConnectException in RequestException.php line 49:
cURL error 7: Failed to connect to localhost port 8080: Connection refused
Still I can make calls to localhost:8080 from web browser.Anyone has any suggestion?
Seeing how your application is running in Homestead (which by default is available on 192.168.10.10 and is forwarded to also be accessible on localhost:8000) your application running on Glassfish will not have access to it using localhost:8080. This is because localhost in your vagrant box (Homestead) is not actually the same localhost as on the host machine.
What you could do is grab the ip address from the host machine and connect to it from your application running in Homestead.
So here is how I could solve the problem. Vagrant is the guest machine running on my localhost as host machine. To access host from guest, you need to use gateway from VB.
I found this answer which helped me to access my application on localhost.

Xcode Server is unavailable

I am trying to setup CI on an Xcode Server. I have a Mac running OSX Server with Xcode Services up and running (seems to be working). The Mac is hosted in the cloud.
When I try to add the server to Xcode on my local Mac dev machine, it says "Xcode Server is unavailable". What "server address" do I use. I tried the IP address as well as the machinename.companyname.com address.
Note I have enabled the "file sharing" service and this works fine using machinename.companyname.com.
I configured my router to forward the relevant traffic to the server. This process is called port forwarding.
Opening these ports worked for me
Protocol Port Range ---- Comment
TCP 22 ---- ssh
TCP 80 ---- http
TCP 443 ---- https
TCP+UDP 3690 ---- svn
TCP+UDP 9418 ---- git
TCP+UDP 20300 ---- xcode1
TCP+UDP 20343-20345 ---- xcode2
reference: https://support.apple.com/en-ae/HT202944
I am having the same problem you are. My server is not in the cloud, but it is setup to be accessible outside of my network. I am able to add my server because it is seen by Bonjour. Everything works fine that way. However, I can't add the server by using the IP or the www address.
I've verified that TCP ports 22, 80, and 443 are forwarding correctly. I also have TCP/UDP 3690 and 9418 forwarded correctly.
One thing I wanted to add is that I can add repositories that exist on the server without issue. It is just adding the server that is causing a problem.
I have filed a bug report with Apple and will comment back here as soon as I get a response.
I think I solved my own problem. After upgrading to Xcode6, need to upgrade to Yosemite too. Don't know why but this seemed to fix the issue.

Resources