Skip to content

Health API Showing OK when unable to connect to database #4575

Closed
@toddheslin

Description

@toddheslin

Issue Description

I've had a recent issue where I was relying on pingdom hitting my /health endpoint expecting that it should show an error if there is a database connection error. Unfortunately this is not the case. The Parse app connects to a local postgres database that crashed and didn't restart. Whilst the application was technically crashed, the health endpoint responded OK.

I've since updated to the latest release and see this is still a problem. Is this intentional, or just overlooked?

Steps to reproduce

  1. Start server
  2. GET /parse/health -> response {"status":"ok"}
  3. Switch off database
  4. Error shows in logs:
{ Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5432 }
warn: Unable to ensure uniqueness for usernames:  Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
warn: Unable to ensure uniqueness for user email addresses:  Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
warn: Unable to ensure uniqueness for role name:  Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
(node:8526) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): Error: connect ECONNREFUSED 127.0.0.1:5432
(node:8526) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:8526) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 9): Error: connect ECONNREFUSED 127.0.0.1:5432
  1. Check health endpoint: GET /parse/health -> response {"status":"ok"}

Expected Results

Health status should not be ok if there is a database connection error

Actual Outcome

Health status returning ok despite the application not able to make receive requests

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.7.2
    • Operating System: macOS 10.13.3
    • Hardware: MacBook Pro
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Localhost
  • Database

    • Postgres version: 9.6.6
    • Storage engine: N/A
    • Hardware: N/A
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Localhost

Logs/Trace

{ Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5432 }
warn: Unable to ensure uniqueness for usernames:  Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
warn: Unable to ensure uniqueness for user email addresses:  Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
warn: Unable to ensure uniqueness for role name:  Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
(node:8899) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): Error: connect ECONNREFUSED 127.0.0.1:5432
(node:8899) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:8899) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 9): Error: connect ECONNREFUSED 127.0.0.1:5432
GET /api/health 200 4.825 ms - 15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions