Nick Kahn
Nick Kahn

Reputation: 20078

This site can’t be reached localhost refused to connect. on empty project

My localhost does not load the page:

http://localhost:8080/ 
This site can’t be reached 
localhost refused to connect.

I have a brand new project and when I run the project I don't get any errors or see any errors but when I try to view using the localhost I see the above error

Here is the detail on my project.

Java version on my machine:

C:\WINDOWS\system32>java -version java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

I have no idea what I'm doing wrong here, and again I have nothing except this class which I run:

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

My POM file:

4.0.0 org.springframework.boot spring-boot-starter-parent 2.4.2 com.example demo 0.0.1-SNAPSHOT demo Demo project for Spring Boot

<properties>
    <java.version>11</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Application log:

2021-01-16 19:24:07.268 INFO 23308 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication using Java 13.0.2 on XPS8910 with PID 23308 (C:\Users\nick\eclipse-workspace\demo\target\classes started by XPS89100 in C:\Users\nick\eclipse-workspace\demo) 2021-01-16 19:24:07.270 INFO 23308 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2021-01-16 19:24:07.740 INFO 23308 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2021-01-16 19:24:07.752 INFO 23308 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 4 ms. Found 0 JPA repository interfaces. 2021-01-16 19:24:08.143 INFO 23308 --- [
main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2021-01-16 19:24:08.151 INFO 23308 --- [
main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2021-01-16 19:24:08.151 INFO 23308 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41] 2021-01-16 19:24:08.274 INFO 23308 --- [
main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2021-01-16 19:24:08.274 INFO 23308 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 961 ms 2021-01-16 19:24:08.429 INFO 23308 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2021-01-16 19:24:08.473 INFO 23308 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.27.Final 2021-01-16 19:24:08.586 INFO 23308 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2021-01-16 19:24:08.670 INFO 23308 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...

Upvotes: 1

Views: 4278

Answers (1)

Monitoria
Monitoria

Reputation: 441

It looks like spring application didn't start completely and freezes on starting Hikari Pool (last line in your log).

Hikari pool is a database connection pool. This probably means that the DB connection settings in your application.properties are incorrect and connection can't be established.

Can you verify that database is running and responding on the datasource URL you configured?

Upvotes: 3

Related Questions