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

macOS Sierra - puma dev only works when run interactively. #66

Closed
idyll opened this issue Aug 15, 2016 · 25 comments
Closed

macOS Sierra - puma dev only works when run interactively. #66

idyll opened this issue Aug 15, 2016 · 25 comments
Labels
closed as stale issues with no activity in over a year

Comments

@idyll
Copy link

idyll commented Aug 15, 2016

I have no idea what's going on here.

If I use the launch agent to start puma-dev things lockup after booting the rails app.
If I run the app interactively, things work correctly.

I will try to turn on extra debugging in the launch agent plist but since it works interactively this is pretty hard to debug.

@evanphx
Copy link
Member

evanphx commented Aug 15, 2016

When puma-dev starts via launchd, can you try to start an app and then run curl -H "Host: puma-dev" localhost/events" and gist the output? That might help us understand more of what is going on.

@evanphx
Copy link
Member

evanphx commented Aug 15, 2016

I'll assume that #67 is the reason for this issue.

@dirksierd
Copy link

I'm also having issues on macOS Sierra. Re-installed a bunch of time and did some debugging, but can't figure out what's wrong. Interactive-mode is working (when adding the port after .dev, eg: dashboard.dev:9280). Background-mode is not responding. All I did was follow the instructions from README.

~ cat /etc/resolver/dev
# Generated by puma-dev
nameserver 127.0.0.1
port 9253
~ ln -l ~/.puma-dev
total 8
lrwxr-xr-x  1 Dirk  staff   38 15 sep 11:44 dashboard -> /Users/Dirk/code/clients/edu_dashboard
drwxr-xr-x  3 Dirk  staff  102 15 sep 11:31 tmp
 ~ cat ~/Library/LaunchAgents/io.puma.dev.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>io.puma.dev</string>
   <key>ProgramArguments</key>
   <array>
     <string>/usr/local/Cellar/puma-dev/0.10/bin/puma-dev</string>
     <string>-launchd</string>
     <string>-dir</string>
     <string>~/.puma-dev</string>
     <string>-d</string>
     <string>dev</string>
     <string>-timeout</string>
     <string>15m0s</string>
   </array>
   <key>KeepAlive</key>
   <true/>
   <key>RunAtLoad</key>
   <true/>
   <key>Sockets</key>
   <dict>
       <key>Socket</key>
       <dict>
           <key>SockNodeName</key>
           <string>0.0.0.0</string>
           <key>SockServiceName</key>
           <string>80</string>
       </dict>
       <key>SocketTLS</key>
       <dict>
           <key>SockNodeName</key>
           <string>0.0.0.0</string>
           <key>SockServiceName</key>
           <string>443</string>
       </dict>
   </dict>
   <key>StandardOutPath</key>
   <string>/Users/Dirk/Library/Logs/puma-dev.log</string>
   <key>StandardErrorPath</key>
   <string>/Users/Dirk/Library/Logs/puma-dev.log</string>
</dict>
</plist>
~ curl -H "Host: puma-dev" localhost/events
curl: (7) Failed to connect to localhost port 80: Connection refused
~ tail ~/Library/Logs/puma-dev.log
* Directory for apps: /Users/Dirk/.puma-dev
* Domains: dev
* DNS Server port: 9253
* HTTP Server port: inherited from launchd
* HTTPS Server port: inherited from launchd
! Puma dev listening on http and https

Requests to dashboard.dev:9253 don't respond (safari keeps loading) and dashboard.dev just fail instantly.

Tried looking into the code, but my Go-skills aren't there to help out.

@soulim
Copy link
Contributor

soulim commented Sep 22, 2016

I can confirm the same issue @dirksierd is having on macOS Sierra. Tried to re-install many a couple times following instructions word by word, but no luck with that. The app is reachable only when puma-dev is running in foreground mode and the port is specified (e.g. http://awesome.dev:9280). The configuration on my machine is exactly the same @dirksierd provided above.

@evanphx please let me know I should create a separate issue for that.

@evanphx evanphx reopened this Sep 23, 2016
@evanphx
Copy link
Member

evanphx commented Sep 23, 2016

@dirksierd @soulim Can you run sudo lsof -i :80 on your machine and gist the output here? That should tell us if maybe there is something else on port 80.

@dirksierd
Copy link

dirksierd commented Sep 23, 2016

@evanphx

~ sudo lsof -i :80
COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
launchd       1 root   11u  IPv4 0x93130d0619c73a35      0t0  TCP *:http (LISTEN)
Newton    22781 Dirk   36u  IPv4 0x93130d0607782f4d      0t0  TCP 172.20.10.4:50968->2.17.226.217:http (ESTABLISHED)
IMTransfe 24749 Dirk    6u  IPv4 0x93130d060f724a35      0t0  TCP 172.20.10.4:50987->wa-in-f128.1e100.net:http (ESTABLISHED)
IMTransfe 24749 Dirk   11u  IPv4 0x93130d0607781d5d      0t0  TCP 172.20.10.4:50959->wa-in-f128.1e100.net:http (ESTABLISHED)
puma-dev  24804 Dirk    8u  IPv4 0x93130d0619c73a35      0t0  TCP *:http (LISTEN)
puma-dev  24804 Dirk    9u  IPv4 0x93130d0619c73a35      0t0  TCP *:http (LISTEN)

Update: 2016-09-23 22:20

COMMAND    PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
launchd      1 root   11u  IPv4 0x93130d0619c73a35      0t0  TCP *:http (LISTEN)
puma-dev 24804 Dirk    8u  IPv4 0x93130d0619c73a35      0t0  TCP *:http (LISTEN)
puma-dev 24804 Dirk    9u  IPv4 0x93130d0619c73a35      0t0  TCP *:http (LISTEN)

@evanphx
Copy link
Member

evanphx commented Sep 23, 2016

Hm, odd that there are 2 puma-dev instances there. Perhaps that's a change that they did in Sierra, but it should still work. So if you do telnet localhost 80 it never connects?

@dirksierd
Copy link

this is what happens…

~ telnet localhost 80
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

@evanphx
Copy link
Member

evanphx commented Sep 23, 2016

That's really odd. Something must have changed in Sierra that is causing the launchd stuff to not work properly. I'm not on Sierra atm (it broke my keyboard driver) so I'll have to see about how to find a way to debug this further.

@dirksierd
Copy link

So I've been using pow in the past, but that no longer works since I'm using ActionCable with Rails.
Anyway: I went through the lines of the uninstall-script of Pow and ran some commands manually. I also cleaned out all the firewall-rules in System Preferences. After all that I re-installed puma-dev and it appears to be working now. Possibly an incomplete uninstall of pow could lead to the aforementioned issues.

@soulim
Copy link
Contributor

soulim commented Sep 25, 2016

When I run sudo lsof -i :80 there is only launchd and puma-dev:

> sudo lsof -i :80
COMMAND  PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
launchd    1   root   45u  IPv4 0x71480a4361491235      0t0  TCP *:http (LISTEN)
puma-dev 669 soulim    8u  IPv4 0x71480a4361491235      0t0  TCP *:http (LISTEN)

telnet localhost 80 gives exactly the same results @dirksierd showed above.

I've used pow before. Now I've going to walk through the pow's uninstall-script. Fingers crossed 😄

@soulim
Copy link
Contributor

soulim commented Sep 25, 2016

Wooohooo! I'm happy to confirm that solution suggested by @dirksierd worked very well for me. Most probably there was something wrong because of incorrectly uninstalled pow.

Thank you very much @dirksierd and @evanphx for your help and support! 😃

@mrsimo
Copy link

mrsimo commented Oct 7, 2016

Also using Sierra here, and getting the exact same things as @dirksierd. We were really interested in a pow alternative that worked with websockets!

Running in the foreground would be an option, but we need to add the port everywhere, which screws things up a bit. Any help would be appreciated!

@soulim
Copy link
Contributor

soulim commented Oct 7, 2016

@mrsimo please make sure you uninstalled pow correctly (e.g. just brew uninstall pow does not work).

On the pow's website you could find instructions. Basically you need to run:

curl get.pow.cx/uninstall.sh | sh

See more at http://pow.cx/manual.html#section_1.2

This worked well for me. I've uninstalled pow and then re-installed puma-dev.

@mrsimo
Copy link

mrsimo commented Oct 10, 2016

Welp, thanks @soulim! I managed to get it to work. I'm 99% sure I ran the uninstall script before–in fact, running curl get.pow.cx/uninstall.sh | sh displayed a Pow not found, but I went through the script steps one by one, and it seems like some of the firewall stuff hadn't run.

I ran it manually and everything's working fine now 👌

@trevorturk
Copy link

@mrsimo thanks for the tip -- I was having trouble with http (https was working) so I stepped through the script at get.pow.cx/uninstall.sh manually and I believe you're right that the firewall stuff hadn't run through correctly.

@joallard
Copy link

In the case the script won't run and I did everything manually, it seemed rm /etc/resolver (yes, even with the right contents) and reinstalling did the trick. Check with scutil --dns, resolver dev should point to port 9253, not 20560.

@ericboehs
Copy link

ericboehs commented Jan 20, 2017

This seems to have fixed it for me: sudo pfctl -F all.

🎉 Thanks to @dirksierd for sending me down the pow uninstall script path. The answer lied there.


The rest of this post is a documentation of my debugging adventure:

I ran into this as well on 10.12.3 Beta (16D30a). I may have had Pow on this machine but I can't remember (pow's uninstall script said it wasn't found).

I'm having the same results as @dirksierd:

❯ lsof -i :9180
COMMAND    PID      USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
puma-dev 30035 ericboehs    6u  IPv4 0x673d0ebc1a6a1bd1      0t0  TCP *:9180 (LISTEN)
puma-dev 30035 ericboehs    8u  IPv4 0x673d0ebc1a6a1bd1      0t0  TCP *:9180 (LISTEN)

❯ telnet localhost 80
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

It doesn't seem to be a difference between foregrounding/daemon but using port 80/443.

  • Changing the puma-dev launchagent to use different ports (9180/9183) works.
  • Changing the puma-dev foreground to use (80/443) does not work (sudo -E puma-dev -http-port 80 -https-port 443)
  • Changing the puma-dev foreground to use ports <1024 does work (sudo -E puma-dev -http-port 180 -https-port 243)
  • Turning the firewall off in Sys Prefs has no effect

After fixing, lsof -i :80 still has two puma-dev listings.

@elliottmason
Copy link

It seems like I have to run sudo pfctl -F all every time I reboot though

@carltonsmith
Copy link

carltonsmith commented Aug 11, 2017

I am not able to run in background either, but it seems like I have a different issue. Puma dev doesn't show up at all when running lsof -i :80 - here is my result
httpd 98 root 4u IPv6 0xbcfe53d84438f2fd 0t0 TCP *:http (LISTEN)
httpd 268 _www 4u IPv6 0xbcfe53d84438f2fd 0t0 TCP *:http (LISTEN)
httpd 3810 _www 4u IPv6 0xbcfe53d84438f2fd 0t0 TCP *:http (LISTEN)

@bradical
Copy link

@carltonsmith yours looks like you've still got Apache running and binding to port 80.

@bradical
Copy link

bradical commented Dec 19, 2017

@ericboehs are you saying you were never able to get puma-dev running on port 80 in either the foreground or background? Anyone else been able to get this working on Sierra? Any better luck on High Sierra?

I've tried:

  • repeatedly uninstalling pow
  • repeatedly uninstalling/installing puma-dev on .dev, .test, .local

I'm currently here:

[~/Dev] $ sudo puma-dev -setup -d local
* Configuring /etc/resolver to be owned by bradley
* Changing '/etc/resolver/dev' to be owned by bradley
* Changing '/etc/resolver/local' to be owned by bradley
* Changing '/etc/resolver/test' to be owned by bradley
[~/Dev] $ puma-dev -install -d local
* Use '/usr/local/Cellar/puma-dev/0.11/bin/puma-dev' as the location of puma-dev
* Installed puma-dev on ports: http 80, https 443

with a tail of:

* Directory for apps: /Users/bradley/.puma-dev
* Domains: local
* DNS Server port: 9253
* HTTP Server port: inherited from launchd
* HTTPS Server port: inherited from launchd
! Puma dev listening on http and https
$ lsof -i :80
COMMAND    PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
puma-dev 16839 bradley    7u  IPv4 0xaaa172d77ca12dd7      0t0  TCP *:http (LISTEN)
puma-dev 16839 bradley   10u  IPv4 0xaaa172d77ca12dd7      0t0  TCP *:http (LISTEN)

$ telnet localhost 80
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

but can't resolve my app:

$ curl http://cascade.local
curl: (6) Could not resolve host: cascade.local

I noticed that scutil --dns shows some differences between .local and .test in particular that first resolver#2 and wondering if that could have anything to do with it. Also wondering if it's a firewall issue but don't know how to check.

DNS configuration
 
resolver #1
  nameserver[0] : 192.168.1.1
  if_index : 4 (en0)
  flags    : Request A records
  reach    : Reachable, Directly Reachable Address
 
resolver #2
  domain   : local
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : Not Reachable
  order    : 300000
 
resolver #3
  domain   : 254.169.in-addr.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : Not Reachable
  order    : 300200
 
resolver #4
  domain   : 8.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : Not Reachable
  order    : 300400
 
resolver #5
  domain   : 9.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : Not Reachable
  order    : 300600
 
resolver #6
  domain   : a.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : Not Reachable
  order    : 300800
 
resolver #7
  domain   : b.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : Not Reachable
  order    : 301000
 
resolver #8
  domain   : dev
  nameserver[0] : 127.0.0.1
  port     : 9253
  flags    : Request A records, Request AAAA records
  reach    : Reachable, Local Address, Directly Reachable Address
 
resolver #9
  domain   : local
  nameserver[0] : 127.0.0.1
  port     : 9253
  flags    : Request A records, Request AAAA records
  reach    : Reachable, Local Address, Directly Reachable Address
 
resolver #10
  domain   : test
  nameserver[0] : 127.0.0.1
  port     : 9253
  flags    : Request A records, Request AAAA records
  reach    : Reachable, Local Address, Directly Reachable Address
 
DNS configuration (for scoped queries)
 
resolver #1
  nameserver[0] : 192.168.1.1
  if_index : 4 (en0)
  flags    : Scoped, Request A records
  reach    : Reachable, Directly Reachable Address

@ericboehs
Copy link

@bradical Did you try the sudo pfctl -F all trick?

@bradical
Copy link

So I ended up putting puma-dev on a new computer recently and it works without issue. It's possible it could have been some leftover settings from pow causing problems.

My process was basically:

$ brew install puma/puma/puma-dev
$ sudo puma-dev -setup
$ sudo puma-dev -install -d test

and it's working now on startup with the following LaunchAgent configuration:

   <array>
     <string>/usr/local/Cellar/puma-dev/0.11/bin/puma-dev</string>
     <string>-launchd</string>
     <string>-dir</string>
     <string>~/.puma-dev</string>
     <string>-d</string>
     <string>test</string>
     <string>-timeout</string>
     <string>15m0s</string>
   </array>
   <key>KeepAlive</key>
   <true/>
   <key>RunAtLoad</key>
   <true/>
   <key>Sockets</key>
   <dict>
       <key>Socket</key>
       <dict>
           <key>SockNodeName</key>
           <string>0.0.0.0</string>
           <key>SockServiceName</key>
           <string>80</string>
       </dict>
       <key>SocketTLS</key>
       <dict>
           <key>SockNodeName</key>
           <string>0.0.0.0</string>
           <key>SockServiceName</key>
           <string>443</string>
       </dict>
   </dict>
   <key>StandardOutPath</key>
   <string>/Users/bradley/Library/Logs/puma-dev.log</string>
   <key>StandardErrorPath</key>
   <string>/Users/bradley/Library/Logs/puma-dev.log</string>
</dict>
</plist>

@jkelleyj
Copy link

If you have to keep running sudo pfctl -F all and you were on POW, check the pf rules to see if you have a rdr setup when making POW work on Yosemite. basecamp/pow#452

I also had a LaunchAgent that was running a script to set those rdr's up.

@nonrational nonrational added the closed as stale issues with no activity in over a year label Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed as stale issues with no activity in over a year
Projects
None yet
Development

No branches or pull requests