Samiulla
That's really an interesting question, to be frank. We can efficiently handle this in below two ways,
1) Pega provides an OOTB REST service to see if the environment is Online/Offline (Down). We can hit the service first to see if the environment is up and running. In the same way, you can ask your target system to host a similar service to determine the environment's online status and verify that before your business process.
https://<<hostName:port/contextName>>/PRRestService/monitor/pingservice/ping
2) As part of error handling in your connector which hits the actual service, make sure you explicitly check if the error code is 503 (Service Unavailable) and end the process with a proper retry mechanism.
Let us know which option works better for you 😊