Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72432

systemctl edit jenkins

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • packaging
    • None

      I just created a new Jenkins instance and I could not start the services.  Based on the logs it shows that 8080 was already used.  See below

      Dec 05 22:10:19 localhost systemd[1]: Started Jenkins Continuous Integration Server.
      ...skipping...
      Dec 05 21:54:11 localhost jenkins[82427]:         at org.eclipse.jetty.server.Server.lambda$doStart$0(Server.java:402)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
      Dec 05 21:54:11 localhost jenkins[82427]:         at org.eclipse.jetty.server.Server.doStart(Server.java:398)
      Dec 05 21:54:11 localhost jenkins[82427]:         at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
      Dec 05 21:54:11 localhost jenkins[82427]:         at winstone.Launcher.<init>(Launcher.java:205)
      Dec 05 21:54:11 localhost jenkins[82427]:         ... 6 more
      Dec 05 21:54:11 localhost jenkins[82427]: Caused by: java.net.BindException: Address already in use
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/sun.nio.ch.Net.bind0(Native Method)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/sun.nio.ch.Net.bind(Net.java:555)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294)
      Dec 05 21:54:11 localhost jenkins[82427]:         at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:339)
      Dec 05 21:54:11 localhost jenkins[82427]:         ... 21 more
      Dec 05 21:54:11 localhost jenkins[82427]: 2023-12-05 21:54:11.995+0000 [id=1]        SEVERE        winstone.Logger#logInternal: Container startup failed
      Dec 05 21:54:11 localhost jenkins[82427]: java.net.BindException: Address already in use
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/sun.nio.ch.Net.bind0(Native Method)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/sun.nio.ch.Net.bind(Net.java:555)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294)
      Dec 05 21:54:11 localhost jenkins[82427]:         at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:339)
      Dec 05 21:54:11 localhost jenkins[82427]: Caused: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8080
      Dec 05 21:54:11 localhost jenkins[82427]:         at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)
      Dec 05 21:54:11 localhost jenkins[82427]:         at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:304)
      Dec 05 21:54:11 localhost jenkins[82427]:         at org.eclipse.jetty.server.Server.lambda$doStart$0(Server.java:402)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      Dec 05 21:54:11 localhost jenkins[82427]:         at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)

      Based on this logs, I follow the command

      systemctl edit jenkins and try to update the port using port 8090 using below values in the file.

      [Service]
      Environment="JENKINS_PORT=8090"

      Saved the file, restarted the services, stopped and started the services but error kept coming back to the same 8080 port already in use.  After restart i go back and put the update in and still will not take it.

      most of the Google answers were to use the above command until I found this.  This is the solution that worked.

      If jenkins installed as linux service, open the file /usr/lib/systemd/system/jenkins.service,search for the content "Environment="JENKINS_PORT=8080". Change the port number to your desired. Execute the commands

       systemctl daemon-reload
       systemctl restart jenkins.service `

      Access the Jenkins in browser with the new port number

      Source: https://askubuntu.com/questions/1398910/changed-jenkins-port-doesnt-applied

      I know it should not work based on your document but it worked.

      The fix i did and that worked, is this good for future use or did not go around the core issue?

            Unassigned Unassigned
            kru83 Kru
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: