Solved
On EC2 instance I am giving wrong credentials for Basic Auth but getting 200 code and with same scenario while doing on local machine it is giving unauthorized exception
Please find the scenario below:

Please find the scenario below:

I'm not sure to what server you are accessing to, but looks like it's not AEM instance(which runs by default on port 4502) - unless you have configured custom port. Please check with the proper vendor to which you are trying to access server, that should solve your problem.
Hope that helps!
Regards,
Santosh
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.