Heroku/Postgres:引起:java.net.ConnectException:连接被拒绝(连接被拒绝)
Posted
技术标签:
【中文标题】Heroku/Postgres:引起:java.net.ConnectException:连接被拒绝(连接被拒绝)【英文标题】:Heroku/Postgres: Caused by: java.net.ConnectException: Connection refused (Connection refused) 【发布时间】:2021-04-24 09:02:19 【问题描述】:我将示例应用程序上传到 heroku 并创建了 postgress 数据库,并且我能够使用 heroku 客户端使用 heroku 数据库提供的相同凭据进行连接,当我使用我的应用程序时https://spring-boot-api-crud.herokuapp.com/
PS:是的,我更新了我的 application.properties
spring.datasource.url=jdbc:postgresql://xxxx.compute-1.amazonaws.com:5432/da1a4sj7krudsj
spring.datasource.username=ckinvlxnnpaagi
spring.datasource.password=e92a92b70c55215dde6a546d90f8a5e4ee37e05fcfc3d853bd76508b8bc7bc90
spring.jps.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.show-sql=true
spring.jpa.hibernate.ddl-auto = update
有人知道发生了什么吗?
我看到了错误,所以我做了一些 heroku 日志
heroku 日志 --tail --app spring-boot-api-crud
我看到以下错误
2021-01-20T01:41:19.017628+00:00 app[web.1]:由以下原因引起: java.net.ConnectException:连接被拒绝(连接被拒绝)
详细错误:
2021-01-20T01:41:19.017616+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) [spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.017616+00:00 app[web.1]: at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.017617+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) [spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.017617+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.017617+00:00 app[web.1]: at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.017618+00:00 app[web.1]: at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.017618+00:00 app[web.1]: at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.017618+00:00 app[web.1]: at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.017619+00:00 app[web.1]: at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.017619+00:00 app[web.1]: at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.017620+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.017620+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.017620+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.017621+00:00 app[web.1]: at net.guides.springboot2.crud.Application.main(Application.java:15) ~[classes!/:0.0.1-SNAPSHOT]
2021-01-20T01:41:19.017621+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.017625+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.017626+00:00 app[web.1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.017626+00:00 app[web.1]: at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.017627+00:00 app[web.1]: at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[springboot2-postgresql-jpa-hibernate-crud-example-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2021-01-20T01:41:19.017627+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[springboot2-postgresql-jpa-hibernate-crud-example-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2021-01-20T01:41:19.017627+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[springboot2-postgresql-jpa-hibernate-crud-example-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2021-01-20T01:41:19.017628+00:00 app[web.1]: at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) ~[springboot2-postgresql-jpa-hibernate-crud-example-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2021-01-20T01:41:19.017628+00:00 app[web.1]: Caused by: java.net.ConnectException: Connection refused (Connection refused)
2021-01-20T01:41:19.017629+00:00 app[web.1]: at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.017629+00:00 app[web.1]: at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.017630+00:00 app[web.1]: at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.017630+00:00 app[web.1]: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.017630+00:00 app[web.1]: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.017631+00:00 app[web.1]: at java.net.Socket.connect(Socket.java:607) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.017631+00:00 app[web.1]: at org.postgresql.core.PGStream.<init>(PGStream.java:70) ~[postgresql-42.2.5.jar!/:42.2.5]
2021-01-20T01:41:19.017632+00:00 app[web.1]: at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:91) ~[postgresql-42.2.5.jar!/:42.2.5]
2021-01-20T01:41:19.017632+00:00 app[web.1]: at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192) ~[postgresql-42.2.5.jar!/:42.2.5]
2021-01-20T01:41:19.017633+00:00 app[web.1]: ... 58 common frames omitted
2021-01-20T01:41:19.017633+00:00 app[web.1]:
2021-01-20T01:41:19.017876+00:00 app[web.1]: 2021-01-20 01:41:19.017 WARN 4 --- [ main] o.h.e.j.e.i.JdbcEnvironmentInitiator : HHH000342: Could not obtain connection to query metadata : Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2021-01-20T01:41:19.021862+00:00 app[web.1]: 2021-01-20 01:41:19.021 WARN 4 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
2021-01-20T01:41:19.029290+00:00 app[web.1]: 2021-01-20 01:41:19.029 INFO 4 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-01-20T01:41:19.105213+00:00 app[web.1]: 2021-01-20 01:41:19.104 INFO 4 --- [ main] ConditionEvaluationReportLoggingListener :
2021-01-20T01:41:19.105214+00:00 app[web.1]:
2021-01-20T01:41:19.105215+00:00 app[web.1]: Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-01-20T01:41:19.113516+00:00 app[web.1]: 2021-01-20 01:41:19.113 ERROR 4 --- [ main] o.s.boot.SpringApplication : Application run failed
2021-01-20T01:41:19.113517+00:00 app[web.1]:
2021-01-20T01:41:19.113531+00:00 app[web.1]: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
2021-01-20T01:41:19.113532+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1699) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113532+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113532+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113533+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113534+00:00 app[web.1]: at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113535+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113535+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113535+00:00 app[web.1]: at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113536+00:00 app[web.1]: at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113536+00:00 app[web.1]: at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113537+00:00 app[web.1]: at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.113537+00:00 app[web.1]: at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.113538+00:00 app[web.1]: at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.113538+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.113538+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.113539+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
2021-01-20T01:41:19.113539+00:00 app[web.1]: at net.guides.springboot2.crud.Application.main(Application.java:15) [classes!/:0.0.1-SNAPSHOT]
2021-01-20T01:41:19.113540+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.113540+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.113541+00:00 app[web.1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.113541+00:00 app[web.1]: at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_275-heroku]
2021-01-20T01:41:19.113541+00:00 app[web.1]: at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [springboot2-postgresql-jpa-hibernate-crud-example-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2021-01-20T01:41:19.113542+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [springboot2-postgresql-jpa-hibernate-crud-example-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2021-01-20T01:41:19.113542+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [springboot2-postgresql-jpa-hibernate-crud-example-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2021-01-20T01:41:19.113549+00:00 app[web.1]: at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [springboot2-postgresql-jpa-hibernate-crud-example-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2021-01-20T01:41:19.113550+00:00 app[web.1]: Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
2021-01-20T01:41:19.113551+00:00 app[web.1]: at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:271) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113551+00:00 app[web.1]: at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113552+00:00 app[web.1]: at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113552+00:00 app[web.1]: at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113552+00:00 app[web.1]: at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113553+00:00 app[web.1]: at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:242) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113553+00:00 app[web.1]: at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113554+00:00 app[web.1]: at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113554+00:00 app[web.1]: at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113555+00:00 app[web.1]: at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:861) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113555+00:00 app[web.1]: at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113556+00:00 app[web.1]: at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113557+00:00 app[web.1]: at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113557+00:00 app[web.1]: at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113558+00:00 app[web.1]: at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113558+00:00 app[web.1]: at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113558+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1758) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113559+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1695) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
2021-01-20T01:41:19.113560+00:00 app[web.1]: ... 24 common frames omitted
2021-01-20T01:41:19.113560+00:00 app[web.1]: Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
2021-01-20T01:41:19.113560+00:00 app[web.1]: at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113561+00:00 app[web.1]: at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113562+00:00 app[web.1]: at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113567+00:00 app[web.1]: at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113568+00:00 app[web.1]: at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113569+00:00 app[web.1]: at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
2021-01-20T01:41:19.113569+00:00 app[web.1]: ... 41 common frames omitted
2021-01-20T01:41:19.113570+00:00 app[web.1]:
2021-01-20T01:41:19.237424+00:00 heroku[web.1]: Process exited with status 1
2021-01-20T01:41:19.356403+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-20T01:41:20.214696+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=spring-boot-api-crud.herokuapp.com request_id=3e10bad4-3afb-4b43-bd30-28a9eebae9e3 fwd="75.10.187.93" dyno= connect
=服务=状态=503字节=协议=https
【问题讨论】:
"Connection denied" 通常意味着服务器阻止了连接,例如因为防火墙或类似的东西。连接尝试甚至没有到达该服务器上运行的 Postgres 服务。 【参考方案1】:日志包含这一行
与 localhost:5432 的连接被拒绝。
您确定使用正确的配置文件运行应用程序吗?
检查 spring.datasource.url 并在正确的配置文件上运行您的应用程序
【讨论】:
以上是关于Heroku/Postgres:引起:java.net.ConnectException:连接被拒绝(连接被拒绝)的主要内容,如果未能解决你的问题,请参考以下文章
如何让我在 Heroku 上的 Laravel 项目使用 Heroku Postgres?
使用 heroku pg:backups:restore 导入 Heroku Postgres
Heroku Postgres 升级后 Flyway 无法连接到数据库
Ruby On Rails Heroku Postgres数据库SSL连接