Why subscription example from the official docs is not working correctly?

Hi I am experiencing a similar issue using the base example (https://github.com/apollographql/docs-examples/blob/main/apollo-server/v4/subscriptions-graphql-ws/src/index.ts). I have implemented exactly as is (copy & paste). I have tried using the ws and wss protocals on the apollo client. I am getting an error " Unable to reach subscription server". When I try to run the

npx diagnose-endpoint@1.1.0 --endpoint=ws://localhost:4000/graphQL

command it displays:
Diagnosing ws://localhost:4000/graphQL
:warning: Could not resolve (ENOTFOUND)
Is the address correct?
Is the server running?

Can someone please advise?