Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy error: Connection refused #284

Open
ledermann opened this issue Oct 26, 2021 · 7 comments
Open

Proxy error: Connection refused #284

ledermann opened this issue Oct 26, 2021 · 7 comments
Labels
question triage needs more discussion / feedback to determine validity

Comments

@ledermann
Copy link

Since a few days all my applications that use puma-dev don't work any more because of this error:

http: proxy error: dial tcp 127.0.0.1:3035: connect: connection refused

I'm using Ruby on Rails and webpack-dev-server with the proxy support, so there is webpack.myapp.test. Accessing https://myapp.test works fine, but https://webpack.myapp.test fails.

From my ~/Library/Logs/puma-dev.log:

Booting app 'myapp-6046cd89' on socket /Users/ledermann/.puma-dev/myapp/tmp/puma-dev-8692.sock
myapp-6046cd89[9306]: Puma starting in single mode...
myapp-6046cd89[9306]: * Puma version: 5.5.2 (ruby 3.0.2-p107) ("Zawgyi")
myapp-6046cd89[9306]: *  Min threads: 0
myapp-6046cd89[9306]: *  Max threads: 5
myapp-6046cd89[9306]: *  Environment: development
myapp-6046cd89[9306]: *          PID: 9306
myapp-6046cd89[9306]: * Listening on unix:/Users/ledermann/.puma-dev/myapp/tmp/puma-dev-8692.sock
myapp-6046cd89[9306]: Use Ctrl-C to stop
! App 'myapp-6046cd89' booted
* Generated proxy connection for 'webpack.myapp' to http://127.0.0.1:3035
2021/10/26 07:42:26 http: proxy error: dial tcp 127.0.0.1:3035: connect: connection refused
2021/10/26 07:42:26 http: proxy error: dial tcp 127.0.0.1:3035: connect: connection refused
2021/10/26 07:42:26 http: proxy error: dial tcp 127.0.0.1:3035: connect: connection refused

It seems that 127.0.0.1:3035 does not work:

~  > curl -I http://127.0.0.1:3035/packs/runtime-656c7133b991c29ebdeb.js
curl: (7) Failed to connect to 127.0.0.1 port 3035: Connection refused

But when I change 127.0.0.1 to localhost, then the response is fine:

~  > curl -I http://localhost:3035/packs/runtime-656c7133b991c29ebdeb.js
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Content-Type: application/javascript; charset=utf-8
Accept-Ranges: bytes
Content-Length: 48565
ETag: W/"bdb5-hdxeShi+obi11mpsudBc4H7L02E"
Vary: Accept-Encoding
Date: Tue, 26 Oct 2021 05:44:18 GMT
Connection: keep-alive
Keep-Alive: timeout=5

It seems there is something broken with 127.0.0.1 on my machine. Are there any hints what I can do? I of course I have uninstalled and reinstalled puma-dev, rebooted the machine and disabled the firewall, but this didn't help.

More about my config:

~  > puma-dev -V
Version: 0.16.2 (go1.16.6)

~  > sw_vers
ProductName:	macOS
ProductVersion:	11.6
BuildVersion:	20G165

~  > nc -zv localhost 9253
nc: connectx to localhost port 9253 (tcp) failed: Connection refused
Connection to localhost port 9253 [tcp/*] succeeded!
~  > nc -zv 127.0.0.1 9253
Connection to 127.0.0.1 port 9253 [tcp/*] succeeded!

~  > ls -l /etc/resolver
total 8
-rw-r--r--  1 ledermann  staff  55 26 Okt 08:06 test

~  > cat /etc/resolver/test
# Generated by puma-dev
nameserver 127.0.0.1
port 9253

~  > ps ax|grep puma
12803   ??  S      0:00.05 /usr/local/bin/puma-dev -launchd -dir ~/.puma-dev -d test -timeout 15m0s -no-serve-public-paths
12839 s003  S+     0:00.01 puma-dev
13363 s004  R+     0:00.00 grep puma

~  > cat ~/.puma-dev/webpack.myapp
3035
@ledermann
Copy link
Author

ledermann commented Oct 26, 2021

After upgrading my machine from macOS 11.6 to 11.6.1 (and the necessary reboot) the problem has gone. Strange.

~  > ps ax|grep puma
 1486   ??  S      0:00.83 /usr/local/bin/puma-dev -launchd -dir ~/.puma-dev -d test -timeout 15m0s -no-serve-public-paths
10638 s003  S+     0:00.00 grep puma

It seems there was an additional puma-dev process running, which is not there anymore. Don't know why this survived multiple reboots before. (wrong assumption)

Because it's all fine now, I close this issue.

@ledermann
Copy link
Author

The problem is back :-( Rebooting helps, but after some time (minutes), accessing the proxy on port 3035 is not possible anymore. This means:

~/Projects/myapp > curl -I https://myapp.test
HTTP/1.1 200 OK
...
Date: Sun, 31 Oct 2021 10:04:06 GMT

~/Projects/myapp > curl -I https://webpack.myapp.test
HTTP/1.1 500 Internal Server Error
Date: Sun, 31 Oct 2021 10:04:11 GMT

The netcat output is:

~/Projects/myapp > nc -zv localhost 9253
nc: connectx to localhost port 9253 (tcp) failed: Connection refused
Connection to localhost port 9253 [tcp/*] succeeded!

~/Projects/myapp > nc -zv 127.0.0.1 9253
Connection to 127.0.0.1 port 9253 [tcp/*] succeeded!

From the puma-dev logs:

~/Projects/myapp > tail -f ~/Library/Logs/puma-dev.log
myapp-50b9e92c[22599]: *  Environment: development
myapp-50b9e92c[22599]: *          PID: 22599
myapp-50b9e92c[22599]: * Listening on unix:/Users/ledermann/.puma-dev/myapp/tmp/puma-dev-1102.sock
myapp-50b9e92c[22599]: Use Ctrl-C to stop
! App 'myapp-50b9e92c' booted
* Generated proxy connection for 'webpack.myapp' to http://127.0.0.1:3035
2021/10/31 11:03:22 http: proxy error: dial tcp 127.0.0.1:3035: connect: connection refused

Any tips on how I can fix the problem?

@ledermann ledermann reopened this Oct 31, 2021
ledermann added a commit to templatus/templatus-vue that referenced this issue Oct 31, 2021
@nonrational nonrational added question triage needs more discussion / feedback to determine validity labels Oct 31, 2021
@nonrational
Copy link
Member

This is a stab in the dark, but have you tried binding your webpack dev server to 0.0.0.0 ?

@ledermann
Copy link
Author

@nonrational Yes, that works - as does 127.0.0.1, which I tried in the meantime.

I wonder why localhost fails, but 127.0.0.1 works. In the webpacker gem the default is localhost, so I prefer to use this instead of a workaround.

BTW: I tried the issue on a second Mac, which behaves the same: Since a few days, localhost fails (which has been worked for years), but 127.0.0.1 works.

@nonrational
Copy link
Member

Can you post the output of dscacheutil -q host -a name localhost, scutil --dns, and confirm that 127.0.0.1 has an entry in /etc/hosts?

@ledermann
Copy link
Author

Ok, here we go:

~  > dscacheutil -q host -a name localhost
name: localhost
ipv6_address: ::1

name: localhost
ip_address: 127.0.0.1
~  > scutil --dns
DNS configuration

resolver #1
  nameserver[0] : 10.0.1.1
  if_index : 5 (en1)
  flags    : Request A records
  reach    : 0x00020002 (Reachable,Directly Reachable Address)

resolver #2
  domain   : local
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300000

resolver #3
  domain   : 254.169.in-addr.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300200

resolver #4
  domain   : 8.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300400

resolver #5
  domain   : 9.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300600

resolver #6
  domain   : a.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300800

resolver #7
  domain   : b.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 301000

resolver #8
  domain   : test
  nameserver[0] : 127.0.0.1
  port     : 9253
  flags    : Request A records, Request AAAA records
  reach    : 0x00030002 (Reachable,Local Address,Directly Reachable Address)

DNS configuration (for scoped queries)

resolver #1
  nameserver[0] : 10.0.1.1
  if_index : 5 (en1)
  flags    : Scoped, Request A records
  reach    : 0x00020002 (Reachable,Directly Reachable Address)
~  > cat /etc/hosts
##
# 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 minio.test
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

@mrhead
Copy link

mrhead commented Nov 1, 2021

I'm experiencing the same issue. I solved it by writing http://localhost:3035 to ~/.puma/webpack-dev-server.memberful AND rebooting the computer. Changing the file content (and restarting puma-dev) without rebooting did not help. Also, rebooting without updating the file did not help either.

I used just the port in ~/.puma/webpack-dev-server.memberful for a long time, but it suddenly stopped working. I'm not sure when. Probably after puma-dev update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question triage needs more discussion / feedback to determine validity
Projects
None yet
Development

No branches or pull requests

3 participants