Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

FirebaseMessagingException: Connection refused on server

Open
#873 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
firebase, java

Research direction

Start by identifying the outbound connection made by FirebaseMessagingClientImpl.sendSingleRequest and compare the localhost and server environments; the issue provides the relevant stack trace and reports Firebase Admin SDK 9.2.0. Check server network access to the remote FCM service and whether this is reproducible with a minimal send. Done means determining whether the failure is caused by the environment or an SDK defect and documenting a reproducible resolution.

Written by the indexing model from the issue text.

Description

needs-triage

Environment:

  • Firebase SDK version: 9.2.0
  • Library version:
  • Firebase Product: Firebase cloud messaging (FCM)

Problem:

I am having a problem using firebase admin sdk to send push notification from a java based web application.
When i run the code from localhost, everything is working and i was initialize the firebase app and send message.
But it is not working on the server.
I am getting following error.

Log:

10:40:24 com.google.firebase.messaging.FirebaseMessagingException: Unknown error while making a remote service call: Connection refused (Connection refused)
10:40:24 at com.google.firebase.messaging.FirebaseMessagingException.withMessagingErrorCode(FirebaseMessagingException.java:51)
10:40:24 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1306)
10:40:24 at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.createException(FirebaseMessagingClientImpl.java:293)
10:40:24 at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.createException(FirebaseMessagingClientImpl.java:282)
10:40:24 at com.google.firebase.internal.AbstractHttpErrorHandler.handleIOException(AbstractHttpErrorHandler.java:63)
10:40:24 at com.google.firebase.internal.ErrorHandlingHttpClient.send(ErrorHandlingHttpClient.java:110)
10:40:24 at com.google.firebase.internal.ErrorHandlingHttpClient.sendAndParse(ErrorHandlingHttpClient.java:72)
10:40:24 at com.google.firebase.messaging.FirebaseMessagingClientImpl.sendSingleRequest(FirebaseMessagingClientImpl.java:127)
10:40:24 at com.google.firebase.messaging.FirebaseMessagingClientImpl.send(FirebaseMessagingClientImpl.java:113)
10:40:24 at com.google.firebase.messaging.FirebaseMessaging$1.execute(FirebaseMessaging.java:141)
10:40:24 at com.google.firebase.messaging.FirebaseMessaging$1.execute(FirebaseMessaging.java:138)
10:40:24 at com.google.firebase.internal.CallableOperation.call(CallableOperation.java:36)
10:40:24 at com.google.firebase.messaging.FirebaseMessaging.send(FirebaseMessaging.java:108)
10:40:24 at com.google.firebase.messaging.FirebaseMessaging.send(FirebaseMessaging.java:90)
10:40:24 at firebase.actions.JA_SendFirebaseMessage.sendFCMMessage(JA_SendFirebaseMessage.java:91)
10:40:24 at firebase.actions.JA_SendFirebaseMessage.executeAction(JA_SendFirebaseMessage.java:57)
10:40:24 at firebase.actions.JA_SendFirebaseMessage.executeAction(JA_SendFirebaseMessage.java:30)
10:40:24 at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:58)
10:40:24 at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:71)
10:40:24 at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:48)
10:40:24 at com.mendix.core.actionmanagement.internal.InternalCoreAction.call(InternalCoreAction.java:57)
10:40:24 at com.mendix.basis.actionmanagement.ActionManager.$anonfun$executeSync$2(ActionManager.scala:104)
10:40:24 at com.mendix.util.classloading.Runner$.withContextClassLoader(Runner.scala:20)
10:40:24 at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.scala:103)
10:40:24 at com.mendix.basis.actionmanagement.UserActionCallBuilderImpl.execute(UserActionCallBuilderImpl.scala:57)
10:40:24 at com.mendix.modules.microflowengine.actions.actioncall.ForegroundJavaAction.doExecute(ForegroundJavaAction.scala:35)
10:40:24 at com.mendix.modules.microflowengine.actions.actioncall.ForegroundJavaAction.doExecute(ForegroundJavaAction.scala:11)
10:40:24 at com.mendix.modules.microflowengine.actions.actioncall.JavaAction.execute(JavaAction.scala:38)
10:40:24 at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.$anonfun$execute$1(MicroflowObject.scala:32)
10:40:24 at scala.Option.flatMap(Option.scala:283)
10:40:24 at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.scala:29)
10:40:24 at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.scala:176)
10:40:24 at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.scala:116)
10:40:24 at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:58)
10:40:24 at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:71)
10:40:24 at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:48)
10:40:24 at com.mendix.core.actionmanagement.internal.InternalCoreAction.call(InternalCoreAction.java:57)
10:40:24 at com.mendix.basis.actionmanagement.ActionManager.$anonfun$executeSync$2(ActionManager.scala:104)
10:40:24 at com.mendix.util.classloading.Runner$.withContextClassLoader(Runner.scala:20)
10:40:24 at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.scala:103)
10:40:24 at com.mendix.basis.actionmanagement.MicroflowCallBuilderImpl.execute(MicroflowCallBuilderImpl.scala:62)
10:40:24 at com.mendix.webui.actions.client.MicroflowRuntimeOperationExecutor.runMicroflow(MicroflowRuntimeOperationExecutor.scala:97)
10:40:24 at com.mendix.webui.actions.client.MicroflowRuntimeOperationExecutor.$anonfun$apply$5(MicroflowRuntimeOperationExecutor.scala:57)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction$Helpers$.$anonfun$liftEither$1(RegularClientAction.scala:30)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction$Helpers$StateHandler.$anonfun$apply$4(RegularClientAction.scala:56)
10:40:24 at com.mendix.webui.requesthandling.helpers.StateHandling.withState(StateHandling.scala:46)
10:40:24 at com.mendix.webui.requesthandling.helpers.StateHandling.withState$(StateHandling.scala:43)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction$Helpers$StateHandler.withState(RegularClientAction.scala:46)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction$Helpers$StateHandler.apply(RegularClientAction.scala:54)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction$Helpers$StateHandler.apply(RegularClientAction.scala:46)
10:40:24 at com.mendix.webui.actions.client.MicroflowRuntimeOperationExecutor.apply(MicroflowRuntimeOperationExecutor.scala:58)
10:40:24 at com.mendix.webui.actions.client.RuntimeOperationAction.$anonfun$apply$1(RuntimeOperationAction.scala:49)
10:40:24 at scala.util.Either.flatMap(Either.scala:352)
10:40:24 at com.mendix.webui.actions.client.RuntimeOperationAction.apply(RuntimeOperationAction.scala:33)
10:40:24 at com.mendix.webui.actions.client.RuntimeOperationAction.apply(RuntimeOperationAction.scala:22)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction$Helpers$.$anonfun$liftEither$1(RegularClientAction.scala:30)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$3(RegularClientAction.scala:120)
10:40:24 at scala.util.Try$.apply(Try.scala:210)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$2(RegularClientAction.scala:120)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$2$adapted(RegularClientAction.scala:118)
10:40:24 at com.mendix.webui.requesthandling.helpers.ContextHandling.$anonfun$inContext$7(ContextHandling.scala:59)
10:40:24 at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
10:40:24 at com.mendix.basis.actionmanagement.ActionMonitoring$.$anonfun$monitor$1(ActionMonitoring.scala:52)
10:40:24 at com.mendix.util.classloading.Runner$.withContextClassLoader(Runner.scala:20)
10:40:24 at com.mendix.basis.actionmanagement.ActionMonitoring$.monitor(ActionMonitoring.scala:52)
10:40:24 at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext(ContextHandling.scala:59)
10:40:24 at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext$(ContextHandling.scala:33)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction.inContext(RegularClientAction.scala:94)
10:40:24 at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext(ContextHandling.scala:30)
10:40:24 at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext$(ContextHandling.scala:22)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction.inContext(RegularClientAction.scala:94)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$1(RegularClientAction.scala:118)
10:40:24 at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
10:40:24 at com.mendix.webui.requesthandling.helpers.ProfileHandling.profileRequest(ProfileHandling.scala:14)
10:40:24 at com.mendix.webui.requesthandling.helpers.ProfileHandling.profileRequest$(ProfileHandling.scala:10)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction.profileRequest(RegularClientAction.scala:94)
10:40:24 at com.mendix.webui.actions.client.RegularClientAction.execute(RegularClientAction.scala:115)
10:40:24 at com.mendix.webui.requesthandling.ClientRequestHandler.handleAction(ClientRequestHandler.scala:96)
10:40:24 at com.mendix.webui.requesthandling.ClientRequestHandler.processRequest(ClientRequestHandler.scala:69)
10:40:24 at com.mendix.externalinterface.connector.RequestHandler.doProcessRequest(RequestHandler.java:37)
10:40:24 at com.mendix.external.connector.MxRuntimeConnector.$anonfun$processRequest$1(MxRuntimeConnector.scala:54)
10:40:24 at com.mendix.external.connector.MxRuntimeConnector.$anonfun$processRequest$1$adapted(MxRuntimeConnector.scala:54)
10:40:24 at com.mendix.util.classloading.Runner$.withContextClassLoader(Runner.scala:20)
10:40:24 at com.mendix.external.connector.MxRuntimeConnector.processRequest(MxRuntimeConnector.scala:54)
10:40:24 at com.mendix.basis.impl.MxRuntimeImpl.processRequest(MxRuntimeImpl.scala:218)
10:40:24 at com.mendix.m2ee.appcontainer.server.handler.RuntimeServlet.service(RuntimeServlet.scala:40)
10:40:24 at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
10:40:24 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
10:40:24 at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1665)
10:40:24 at org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:170)
10:40:24 at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
10:40:24 at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)
10:40:24 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:527)
10:40:24 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
10:40:24 at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1570)
10:40:24 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
10:40:24 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1384)
10:40:24 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
10:40:24 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)
10:40:24 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1543)
10:40:24 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
10:40:24 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
10:40:24 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
10:40:24 at org.eclipse.jetty.server.Server.handle(Server.java:563)
10:40:24 at org.eclipse.jetty.server.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1598)
10:40:24 at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:753)
10:40:24 at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:501)
10:40:24 at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
10:40:24 at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
10:40:24 at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
10:40:24 at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
10:40:24 at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:421)
10:40:24 at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:390)
10:40:24 at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:277)
10:40:24 at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:199)
10:40:24 at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:411)
10:40:24 at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
10:40:24 at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
10:40:24 at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
10:40:24 at java.base/java.lang.Thread.run(Unknown Source)
10:40:24 Caused by: java.net.ConnectException: Connection refused (Connection refused)
10:40:24 at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
10:40:24 at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
10:40:24 at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
10:40:24 at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
10:40:24 at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
10:40:24 at java.base/java.net.Socket.connect(Unknown Source)
10:40:24 at java.base/sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
10:40:24 at java.base/sun.net.NetworkClient.doConnect(Unknown Source)
10:40:24 at java.base/sun.net.www.http.HttpClient.openServer(Unknown Source)
10:40:24 at java.base/sun.net.www.http.HttpClient.openServer(Unknown Source)
10:40:24 at java.base/sun.net.www.protocol.https.HttpsClient.(Unknown Source)
10:40:24 at java.base/sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
10:40:24 at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
10:40:24 at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
10:40:24 at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
10:40:24 at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
10:40:24 at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
10:40:24 at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
10:40:24 at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
10:40:24 at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:113)
10:40:24 at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:84)
10:40:24 at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1012)
10:40:24 at com.google.firebase.internal.ErrorHandlingHttpClient.send(ErrorHandlingHttpClient.java:96)
10:40:24 ... 115 more

Code:

Initialising firebase app

if(FirebaseApp.getApps().isEmpty()) { FirebaseOptions options = FirebaseOptions.builder().setCredentials(GoogleCredentials.fromStream(serviceAccountKeyFileStream)).build(); try { FirebaseApp.initializeApp(options); } catch (Exception e) { logger.info("FirebaseApp initialised failed."); throw new com.mendix.systemwideinterfaces.MendixRuntimeException("Initialising FirebaseApp failed.\n"+e); } }

Sending message

`Message message = Message.builder()
.putData("title", firebaseMessage.getTitle())
.putData("body", firebaseMessage.getBody())
.putData("url", firebaseMessage.getUrl())
.setToken(firebaseMessage.getToken())
.build();

var messagingInstance = FirebaseMessaging.getInstance();
var response = messagingInstance.send(message);`

Dominant language
Java
Stars
620
Forks
305
Avg merge
3h 23m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-admin-java

All issues in firebase/firebase-admin-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.