On adding Gitea Server (using Gitea jenkins plugin), it does not connect to Gitea server instance giving "java.net.ConnectException: Connection refused" error. So, I thought this might be an error of Gitea jenkins plugin and tried this for GitLab, but receiving same error, when adding GitLab Server (using GitLab Branch Source jenkins plugin).
I am using Multibranch pipeline job, on Jenkins version 2.387.3
Note that credentials are correct and created using the API token created for a user in Gitea (or GitLab) instance as per the steps mentioned in resp. plugin documentation.
Note that if I do not use Gitea (or GitLab) jenkins plugin and select simply "Git" as Branch Source and provide repository URL, while configuring Multibranch Pipeline, then this error does not appear at all.
I tried to increase the global build time or edit other settings in jenkins, but no help. Note for Gitea jenkins plugin, it was working in start but later got these errors, and then kept on regularly getting errors. For GitLab plugin, got these errors right from beginning.
Note Jenkins, Gitea and GitLab are all behind (ufw) firewall on Linux VM servers, with proper rules added. I tried disabling firewall on jenkins and suddenly these errors were gone, but I did not start back work on it for a week and later on, again got these errors even after disabling firewall on jenkins.
Started by user admin
Looking up repository Jangoo/hello_world
java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:305)
at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:507)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:602)
at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)
at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:373)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:207)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:193)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:168)
at org.jenkinsci.plugin.gitea.client.impl.DefaultGiteaConnection.getObject(DefaultGiteaConnection.java:860)
at org.jenkinsci.plugin.gitea.client.impl.DefaultGiteaConnection.fetchRepository(DefaultGiteaConnection.java:200)
at org.jenkinsci.plugin.gitea.GiteaSCMSource.retrieve(GiteaSCMSource.java:187)
at jenkins.scm.api.SCMSource.fetch(SCMSource.java:581)
at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:99)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:312)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:442)
Finished: FAILURE