Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

brew services httpd22 and postgresql are shown as started, but can not connect to them #50065

Closed
afarber opened this issue Mar 13, 2016 · 3 comments

Comments

@afarber
Copy link

afarber commented Mar 13, 2016

Hello,

on Mac OS X El Capitan I have installed Homebrew and then run:

brew update
brew install postgres
brew install homebrew/apache/httpd22
brew install homebrew/php/php53
brew tap homebrew/services

Then in the troubleshooting process I have run:

xcode-select --install
brew update
brew update
sudo chown -R $(whoami) $(brew --prefix)

And rebooted my Macbook Air. Also the Firewall is off in "Security & Privacy settings.

My problem is that while the installed services are shown as being "started", I can not connect to 127.0.0.1:8080 with browser or to /tmp/.s.PGSQL.5432 with psql. Also "netstat" does not show any service listening at port 8080:

screen shot 2016-03-13 at 08 54 17

Please advise how to proceed with this issue.

I see the config files /usr/local/etc/apache2/2.2/httpd.conf but where to find Apache and PostgreSQL startup logs?

Thank you
Alex

P.S. I have asked the same question at
http://superuser.com/questions/1052154/brew-services-httpd22-and-postgresql-are-shown-as-started-but-can-not-connect-t

@MikeMcQuaid
Copy link
Member

I recommend running ps aux | grep -i postgres and similar for the other services and trying to run them manually (as detailed with brew info) which should show you why they haven't started.

@westoque
Copy link

@afarber I had the issue before and had just finally figured it out now. Note, you should not run these commands inside tmux if you are using it. I have no idea why my steps below works, what I did notice was everytime I was doing brew services start postgresl, homebrew adds the file ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist and then removes it when I do brew services stop postgresql. The file should've always been there regardless.

So after, that, here's what I did:

  1. Stop postgresql first by running

    brew services stop postgresql
    
  2. Look for homebrew.mxcl.postgresql.plist in ~/Library/LaunchAgents. It should not be there.

  3. Do brew info postgresql. It will show you something like:

    postgresql: stable 9.5.2 (bottled)
    Object-relational database system
    https://www.postgresql.org/
    Conflicts with: postgres-xc
    /usr/local/Cellar/postgresql/9.5.0 (3,122 files, 34.9M) *
      Poured from bottle
    From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/postgresql.rb
    ==> Dependencies
    Required: openssl ✔, readline ✔
    ==> Options
    --32-bit
            Build 32-bit only
    --with-dtrace
            Build with DTrace support
    --with-python
            Build with python support
    --without-perl
            Build without Perl support
    --without-tcl
            Build without Tcl support
    ==> Caveats
    If builds of PostgreSQL 9 are failing and you have version 8.x installed,
    you may need to remove the previous version first. See:
      https://github.com/Homebrew/homebrew/issues/2510
    
    To migrate existing data from a previous major version (pre-9.0) of PostgreSQL, see:
      http://www.postgresql.org/docs/9.5/static/upgrading.html
    
    To migrate existing data from a previous minor version (9.0-9.4) of PosgresSQL, see:
      http://www.postgresql.org/docs/9.5/static/pgupgrade.html
    
      You will need your previous PostgreSQL installation from brew to perform `pg_upgrade`.
      Do not run `brew cleanup postgresql` until you have performed the migration.
    
    To have launchd start postgresql at login:
      ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
    Then to load postgresql now:
      launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    Or, if you don't want/need launchctl, you can just run:
      postgres -D /usr/local/var/postgres
    
    WARNING: launchctl will fail when run under tmux.
    
  4. Run ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents as specified at the bottom of brew info postgresql command or something similar depending on your case.

  5. Do brew services start postgresql. It should work by now.

@MikeMcQuaid
Copy link
Member

Note, you should not run these commands inside tmux if you are using it.

Thanks for the reminder. I'll add some code to homebrew-services at some point to check this.

@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants