puma-dev: OSX High Sierra: can't listen on port 80

I’m not sure what I’m doing wrong but puma-dev works fine on any port except for port 80:

This works as expected:

sudo puma-dev -dir /Users/me/.puma-dev --http-port 81 --https-port 443 -d dev:test:localhost 

This does not:

$ sudo puma-dev -dir /Users/me/.puma-dev --http-port 80 --https-port 443 -d dev:test:localhost
* Directory for apps: /Users/me/.puma-dev
* Domains: dev, test, localhost
* DNS Server port: 9253
* HTTP Server port: 80
* HTTPS Server port: 443
! Puma dev listening on http and https
^C! Shutdown requested

I get “connection refused”:

curl -vH "Host: puma-dev" localhost/events
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connection failed
* connect to 127.0.0.1 port 80 failed: Connection refused
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 80 failed: Connection refused
* Failed to connect to localhost port 80: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 80: Connection refused

lsof tells me nothing is listening on port 80 except for puma-dev:

$ sudo lsof -i 4tcp |grep ":http "
puma-dev   4383 root    5u  IPv4 0xdd95588c6c9e0223      0t0  TCP localhost:http (LISTEN)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 31 (3 by maintainers)

Most upvoted comments

@thom-nic I did previously have pow installed and I think that may have been the source of my problems

After running your suggested code to remove pow

  • removing the resolvers with rm -rf /etc/resover
  • running sudo pfctl -F all
  • uninstalling puma-dev with puma-dev -uninstall
  • Re-setting up puma-dev sudo puma-dev -setup
  • And then running puma-dev -install -d test

I was able to get puma dev to start working on port 80.

Ok so here’s something: https://superuser.com/a/598287/220180

launchd listens on port 80, as evidenced by:

$ sudo lsof -i ':80'
Password:
COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
launchd     1 root   37u  IPv4 0x32e36f5b72225a51      0t0  TCP *:http (LISTEN)
puma-dev 2703 thom    6u  IPv4 0x32e36f5b72225a51      0t0  TCP *:http (LISTEN)

And puma-dev is designed to have port 80 “handed off” from launchd a la xinetd. However unlike in the SO thread, I’m not and have never run apache httpd on this machine.

It got me thinking, pow does not work via launchd and I think uses some firewall rules instead. As a last ditch, I made sure any trace of pow was removed from my system. ref: http://get.pow.cx/uninstall.sh

launchctl unload ~/Library/LaunchAgents/cx.pow.powd.plist 
rm -f ~/Library/LaunchAgents/cx.pow.powd.plist 
sudo pfctl -a "com.apple/250.PowFirewall" -F all
sudo launchctl unload /Library/LaunchDaemons/cx.pow.firewall.plist
sudo rm /Library/LaunchDaemons/cx.pow.firewall.plist

When I ran pfctl flush the last line of output was pfctl: Anchor or Ruleset does not exist. so I’m not sure that did anything pertinent. However at the moment I seem to now be able to curl http://foo.test with success!

@bpollack @bullfight since you sound like you’re actually experiencing the same problem I was, suggest investigating whether any trace of pow remains on affected machine(s).

This might be related to https://github.com/puma/puma-dev/issues/66 ? I remember having to run sudo pfctl -F all after every reboot before puma-dev would work.

@dmc2015 Interesting thought on whether the change in localhost might be related. But re EventMachine, this project is written in Go - regular Puma is written in Ruby but has its own I/O event reactor, too.

Chrome is now forcing all .dev domains to HTTPS via pre-loaded HSTS. See here for further info: Related Article

Don’t know if there’s a quick fix to this other than changing your local domain ext from .dev to something like .test