Handle Exception – “bad request this combination of host and port requires TLS” or not

When running or planning to run a website, the most look after thing is security. The HTTP is not a secure way to communicate between server and client. We always go for HTTPS, and to enable it, we use the TLS (transport layer security) in the application. It is used to protect data between server and client in transit. TLS is the successor of SSL, and both are used interchangeably. When using TLS protocol, you may get ‘”bad request this combination of host and port requires TLS” or not’.  

You don’t need to worry as we can help you get rid of this exception with the best possible solutions. But before that, let’s have a look at how you encounter error warning

How the error occurs

When you are working with Spring Boot, you get the error once you compile the program. Have a look at the program that you are trying to use

then you may have added

Controller code

 public class MainApplication {
  @RequestMapping(value = "/points/{point}/search", method = RequestMethod.GET)
  public PointsType getPoint(@PathVariable(value = "point") String point) {
  System.out.println("hi"); // Never printed
  return null;
  public static void main(String[] args) {
  SpringApplication.run(MainApplication.class, args);

The application.properties file


As soon as you operate the program, you get the error warning

Could not get any response
 There was an error connecting to https://localhost:8081/points/12345/search.

This is how you land up in trouble. Have a look at the solution section

Solutions to Fix ‘”bad request this combination of host and port requires TLS” or not’

The wrong certification leads to error. The use of a server certificate is the main root cause of the error.  Check out the solutions

Solution 1 – Change the Protocol

A minor change can have a meaningful result. You may have already used the default protocol as https, but at the time of calling, you also need to use the same default protocol instead of http.

So, you need to use https instead of http. This solution can be helpful to get rid of the error warning.

Solution 2 – Have a client certificate

When you install a server certificate on your domain, you get an error warning pops up. There are times when you get confused between the client certificate and the server certificate. It may happen, but as soon as you get the error message, you need to check the certificate. To make a request, you need to use the client certificate. Using the client certificate can solve the error warning.


Here you have the solutions to handle the exception ‘”bad request this combination of host and port requires TLS” or not’. You can simply remove the error warning with a few fixes.

I hope you find it helpful!

If you like solutions, drop a message in the below comment box.

Reference Source:


Leave a Reply

Your email address will not be published. Required fields are marked *