Dead Stuck: Need help in running Elasticsearch and Sonarqube on a Free Tier AWS instance on Ubuntu

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • sonarqube-9.9.4.87374
  • how is SonarQube deployed: zip, Docker, Helm
  • what are you trying to achieve
  • Need help in running Elasticsearch and Sonarqube on a Free Tier AWS instance on Ubuntu
  • what have you tried so far to achieve this
  • I would like to share a few files which can easily tell and the stacktrace which will clear the picture.

The story is that I am trying to configure a DEVOPS pipeline on AWS Free Tier instance using ubuntu.
I am following youtube videos:
I installed:

  • openjdk version “17.0.10” 2024-01-16
  • Apache Maven 3.6.3
  • sonarqube-9.9.4.87374
  • I have configured sonarqube like this:

root@ip-172-31-26-106:/usr/lib/jvm/java-17-openjdk-amd64/bin# nano /opt/sonarqube-9.9.4.87374/conf/sonar.properties
  GNU nano 4.8                                                              /opt/sonarqube-9.9.4.87374/conf/sonar.properties
#sonar.log.level.web=INFO
#sonar.log.level.ce=INFO
#sonar.log.level.es=INFO

# Path to log files. Can be absolute or relative to installation directory.
# Default is <installation home>/logs
sonar.path.logs=/opt/sonarqube-9.9.4.87374/logs

# Rolling policy of log files
#    - based on time if value starts with "time:", for example by day ("time:yyyy-MM-dd")
#      or by month ("time:yyyy-MM")
#    - based on size if value starts with "size:", for example "size:10MB"
#    - disabled if value is "none".  That needs logs to be managed by an external system like logrotate.
#sonar.log.rollingPolicy=time:yyyy-MM-dd

# Maximum number of files to keep if a rolling policy is enabled.
#    - maximum value is 20 on size rolling policy
#    - unlimited on time rolling policy. Set to zero to disable old file purging.
#sonar.log.maxFiles=7

# Access log is the list of all the HTTP requests received by server. If enabled, it is stored
# in the file {sonar.path.logs}/access.log. This file follows the same rolling policy as other log file
# (see sonar.log.rollingPolicy and sonar.log.maxFiles).
#sonar.web.accessLogs.enable=true

# Format of access log. It is ignored if sonar.web.accessLogs.enable=false. Possible values are:
#    - "common" is the Common Log Format, shortcut to: %h %l %u %user %date "%r" %s %b
#    - "combined" is another format widely recognized, shortcut to: %h %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}"
#    - else a custom pattern. See http://logback.qos.ch/manual/layouts.html#AccessPatternLayout.
# The login of authenticated user is not implemented with "%u" but with "%reqAttribute{LOGIN}" (since version 6.1).
# The value displayed for anonymous users is "-".
# The SonarQube's HTTP request ID can be added to the pattern with "%reqAttribute{ID}" (since version 6.2).
# If SonarQube is behind a reverse proxy, then the following value allows to display the correct remote IP address:
#sonar.web.accessLogs.pattern=%i{X-Forwarded-For} %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}" "%reqAttribute{ID}"
# Default value (which was "combined" before version 6.2) is equivalent to "combined + SQ HTTP request ID":
#sonar.web.accessLogs.pattern=%h %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}" "%reqAttribute{ID}"


#--------------------------------------------------------------------------------------------------
# OTHERS

# Delay in seconds between processing of notification queue. Default is 60 seconds.
#sonar.notifications.delay=60

# Paths to persistent data files (embedded database and search index) and temporary files.
# Can be absolute or relative to installation directory.
# Defaults are respectively <installation home>/data and <installation home>/temp
#sonar.path.data=data
#sonar.path.temp=temp

# Telemetry - Share anonymous SonarQube statistics
# By sharing anonymous SonarQube statistics, you help us understand how SonarQube is used so we can improve the product to work even better for you.
# We don't collect source code or IP addresses. And we don't share the data with anyone else.
#sonar.telemetry.enable=true

Then I have configured elasticsearch.yml like this:

root@ip-172-31-26-106:/usr/lib/jvm/java-17-openjdk-amd64/bin# nano nano /opt/sonarqube-9.9.4.87374/elasticsearch/config/elasticsearch.yml
  [1/1]   /opt/sonarqube-9.9.4.87374/elasticsearch/config/elasticsearch.yml

network.host: 51.20.123.29

#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9350

#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["16.171.235.143"]

#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don’t have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features.
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html

– - /opt/sonarqube-9.9.4.87374/logs/sonar.log

2024.04.09 07:57:13 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube-9.9.4.87374/temp
2024.04.09 07:57:13 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:36563]
2024.04.09 07:57:13 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [/opt/sonarqube-9.9.4.87374/elasticsearch]: /opt/sonarqube-9.9.4.87374/elasticsearch/bin/elasticsearch
2024.04.09 07:57:13 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2024.04.09 07:57:14 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [ElasticSearch]: 137
2024.04.09 07:57:14 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2024.04.09 07:57:14 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
2024.04.09 08:06:46 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube-9.9.4.87374/temp
2024.04.09 08:06:46 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:45119]
2024.04.09 08:06:46 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [/opt/sonarqube-9.9.4.87374/elasticsearch]: /opt/sonarqube-9.9.4.87374/elasticsearch/bin/elasticsearch
2024.04.09 08:06:46 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2024.04.09 08:06:47 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [ElasticSearch]: 137
2024.04.09 08:06:47 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2024.04.09 08:06:47 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
2024.04.09 09:03:14 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube-9.9.4.87374/temp
  • /opt/sonarqube-9.9.4.87374/logs/elasticsearch.log
org.elasticsearch.bootstrap.StartupException: BindTransportException[Failed to bind to 16.171.235.143:[9300-9400]]; nested: BindException[Cannot assign requested address];
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:173) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:160) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112) ~[elasticsearch-cli-7.17.15.jar:7.17.15]
        at org.elasticsearch.cli.Command.main(Command.java:77) ~[elasticsearch-cli-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:125) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80) ~[elasticsearch-7.17.15.jar:7.17.15]
Caused by: org.elasticsearch.transport.BindTransportException: Failed to bind to 16.171.235.143:[9300-9400]
        at org.elasticsearch.transport.TcpTransport.bindToPort(TcpTransport.java:453) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.transport.TcpTransport.bindServer(TcpTransport.java:414) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.transport.netty4.Netty4Transport.doStart(Netty4Transport.java:141) ~[?:?]
        at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:48) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.transport.TransportService.doStart(TransportService.java:318) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:48) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.node.Node.start(Node.java:1176) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:335) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:443) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:169) ~[elasticsearch-7.17.15.jar:7.17.15]
        ... 6 more
Caused by: java.net.BindException: Cannot assign requested address
        at sun.nio.ch.Net.bind0(Native Method) ~[?:?]
        at sun.nio.ch.Net.bind(Net.java:555) ~[?:?]
        at sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337) ~[?:?]
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294) ~[?:?]
        at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:141) ~[?:?]
        at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562) ~[?:?]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334) ~[?:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:600) ~[?:?]
        at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:579) ~[?:?]
        at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973) ~[?:?]
        at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260) ~[?:?]
        at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356) ~[?:?]
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[?:?]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[?:?]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[?:?]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) ~[?:?]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[?:?]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[?:?]
        at java.lang.Thread.run(Thread.java:840) [?:?]
[2024-04-13T07:26:48,312][INFO ][o.e.n.Node               ] [ip-172-31-26-106] stopping ...
[2024-04-13T07:26:51,475][INFO ][o.e.n.Node               ] [ip-172-31-26-106] version[7.17.15], pid[12821], build[default/tar/0b8ecfb4378335f4689c4223d1f1115f16bef3ba/2023-11-10T22:03:46.98739901>
[2024-04-13T07:26:51,484][INFO ][o.e.n.Node               ] [ip-172-31-26-106] JVM home [/usr/lib/jvm/java-17-openjdk-amd64]
[2024-04-13T07:26:51,491][INFO ][o.e.n.Node               ] [ip-172-31-26-106] JVM arguments [-Djava.io.tmpdir=/opt/sonarqube-9.9.4.87374/elasticsearch/TempDir, -XX:+HeapDumpOnOutOfMemoryError, -X>
[2024-04-13T07:26:52,168][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] loaded module [analysis-common]
[2024-04-13T07:26:52,169][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] loaded module [lang-painless]
[2024-04-13T07:26:52,170][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] loaded module [parent-join]
[2024-04-13T07:26:52,171][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] loaded module [reindex]
[2024-04-13T07:26:52,172][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] loaded module [transport-netty4]
[2024-04-13T07:26:52,173][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] no plugins loaded
[2024-04-13T07:26:52,222][INFO ][o.e.e.NodeEnvironment    ] [ip-172-31-26-106] using [1] data paths, mounts [[/ (/dev/root)]], net usable_space [22.7gb], net total_space [28.8gb], types [ext4]
[2024-04-13T07:26:52,223][INFO ][o.e.e.NodeEnvironment    ] [ip-172-31-26-106] heap size [226.2mb], compressed ordinary object pointers [true]
[2024-04-13T07:26:52,335][INFO ][o.e.n.Node               ] [ip-172-31-26-106] node name [ip-172-31-26-106], node ID [hgEBexwBSFuvBj4VDlUa5A], cluster name [elasticsearch], roles [data_frozen, mas>
[2024-04-13T07:26:52,448][INFO ][i.n.u.i.PlatformDependent] [ip-172-31-26-106] Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly reques>
  • The jvm.options file is like this:
root@ip-172-31-26-106:/opt/sonarqube-9.9.4.87374/elasticsearch/config# nano jvm.options
  GNU nano 4.8                                                                      jvm.options
################################################################
##
## JVM configuration
##
################################################################
##
## WARNING: DO NOT EDIT THIS FILE. If you want to override the
## JVM options in this file, or set any additional options, you
## should create one or more files in the jvm.options.d
## directory containing your adjustments.
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/7.17/jvm-options.html
## for more information.
##
################################################################



################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/7.17/heap-size.html
## for more information
##
################################################################


################################################################
## Expert settings
################################################################
##
## All settings below here are considered expert settings. Do
## not adjust them unless you understand what you are doing. Do
  • I have created user: sonar and elasticsearch as well:

So there are TWO problems that I am facing when I try to run sonarqube or elasticsearch either from root or from sonar user. I am unable to launch sonarqube on any IP Address, whether 127.0.0.1 or
51.20.128.103 Similarly, neither the elastic search is running from root or elasticsearch user nor sonarqube is running from sonar user.

root@ip-172-31-26-106:/opt/sonarqube-9.9.4.87374/elasticsearch/bin# sudo su elasticsearch
elasticsearch@ip-172-31-26-106:/opt/sonarqube-9.9.4.87374/elasticsearch/bin$ ./elasticsearch

[0.001s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:logs/gc.log instead.
[0.002s][warning][gc] -XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead.
[2024-04-13T08:17:27,438][INFO ][o.e.n.Node               ] [ip-172-31-26-106] version[7.17.15], pid[33064], build[default/tar/0b8ecfb4378335f4689c4223d1f1115f16bef3ba/2023-11-10T22:03:46.987399016Z], OS[Linux/5.15.0-1056-aws/amd64], JVM[Private Build/OpenJDK 64-Bit Server VM/17.0.10/17.0.10+7-Ubuntu-120.04.1]
[2024-04-13T08:17:27,454][INFO ][o.e.n.Node               ] [ip-172-31-26-106] JVM home [/usr/lib/jvm/java-17-openjdk-amd64]
[2024-04-13T08:17:27,478][INFO ][o.e.n.Node               ] [ip-172-31-26-106] JVM arguments [-Djava.io.tmpdir=/opt/sonarqube-9.9.4.87374/elasticsearch/TempDir, -XX:+HeapDumpOnOutOfMemoryError, -XX:+ExitOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -Xloggc:logs/gc.log, -Des.path.home=/opt/sonarqube-9.9.4.87374/elasticsearch, -Des.path.conf=/opt/sonarqube-9.9.4.87374/elasticsearch/config, -Des.distribution.flavor=default, -Des.distribution.type=tar, -Des.bundled_jdk=false]
[2024-04-13T08:17:28,908][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] loaded module [analysis-common]
[2024-04-13T08:17:28,909][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] loaded module [lang-painless]
[2024-04-13T08:17:28,910][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] loaded module [parent-join]
[2024-04-13T08:17:28,910][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] loaded module [reindex]
[2024-04-13T08:17:28,911][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] loaded module [transport-netty4]
[2024-04-13T08:17:28,912][INFO ][o.e.p.PluginsService     ] [ip-172-31-26-106] no plugins loaded
[2024-04-13T08:17:29,036][INFO ][o.e.e.NodeEnvironment    ] [ip-172-31-26-106] using [1] data paths, mounts [[/ (/dev/root)]], net usable_space [22.7gb], net total_space [28.8gb], types [ext4]
[2024-04-13T08:17:29,036][INFO ][o.e.e.NodeEnvironment    ] [ip-172-31-26-106] heap size [226.2mb], compressed ordinary object pointers [true]
[2024-04-13T08:17:29,317][INFO ][o.e.n.Node               ] [ip-172-31-26-106] node name [ip-172-31-26-106], node ID [hgEBexwBSFuvBj4VDlUa5A], cluster name [elasticsearch], roles [data_frozen, master, remote_cluster_client, data, data_content, data_hot, data_warm, data_cold, ingest]
[2024-04-13T08:17:29,524][INFO ][i.n.u.i.PlatformDependent] [ip-172-31-26-106] Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
[2024-04-13T08:17:38,476][INFO ][o.e.t.NettyAllocator     ] [ip-172-31-26-106] creating NettyAllocator with the following configs: [name=unpooled, suggested_max_allocation_size=1mb, factors={es.unsafe.use_unpooled_allocator=null, g1gc_enabled=false, g1gc_region_size=0b, heap_size=226.2mb}]
[2024-04-13T08:17:38,599][INFO ][o.e.i.r.RecoverySettings ] [ip-172-31-26-106] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]
[2024-04-13T08:17:38,748][INFO ][o.e.d.DiscoveryModule    ] [ip-172-31-26-106] using discovery type [zen] and seed hosts providers [settings]
[2024-04-13T08:17:39,567][INFO ][o.e.g.DanglingIndicesState] [ip-172-31-26-106] gateway.auto_import_dangling_indices is disabled, dangling indices will not be automatically detected or imported and must be managed manually
[2024-04-13T08:17:40,060][INFO ][o.e.n.Node               ] [ip-172-31-26-106] initialized
[2024-04-13T08:17:40,060][INFO ][o.e.n.Node               ] [ip-172-31-26-106] starting ...
[2024-04-13T08:17:40,555][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [ip-172-31-26-106] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: BindTransportException[Failed to bind to 16.171.235.143:[9300-9400]]; nested: BindException[Cannot assign requested address];
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:173) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:160) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112) ~[elasticsearch-cli-7.17.15.jar:7.17.15]
        at org.elasticsearch.cli.Command.main(Command.java:77) ~[elasticsearch-cli-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:125) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80) ~[elasticsearch-7.17.15.jar:7.17.15]
Caused by: org.elasticsearch.transport.BindTransportException: Failed to bind to 16.171.235.143:[9300-9400]
        at org.elasticsearch.transport.TcpTransport.bindToPort(TcpTransport.java:453) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.transport.TcpTransport.bindServer(TcpTransport.java:414) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.transport.netty4.Netty4Transport.doStart(Netty4Transport.java:141) ~[?:?]
        at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:48) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.transport.TransportService.doStart(TransportService.java:318) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:48) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.node.Node.start(Node.java:1176) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:335) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:443) ~[elasticsearch-7.17.15.jar:7.17.15]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:169) ~[elasticsearch-7.17.15.jar:7.17.15]
        ... 6 more
Caused by: java.net.BindException: Cannot assign requested address
        at sun.nio.ch.Net.bind0(Native Method) ~[?:?]
        at sun.nio.ch.Net.bind(Net.java:555) ~[?:?]
        at sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337) ~[?:?]
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294) ~[?:?]
        at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:141) ~[?:?]
        at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562) ~[?:?]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334) ~[?:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:600) ~[?:?]
        at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:579) ~[?:?]
        at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973) ~[?:?]
        at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260) ~[?:?]
        at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356) ~[?:?]
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[?:?]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[?:?]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[?:?]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) ~[?:?]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[?:?]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[?:?]
        at java.lang.Thread.run(Thread.java:840) [?:?]
uncaught exception in thread [main]
BindTransportException[Failed to bind to 16.171.235.143:[9300-9400]]; nested: BindException[Cannot assign requested address];
Likely root cause: java.net.BindException: Cannot assign requested address
        at java.base/sun.nio.ch.Net.bind0(Native Method)
        at java.base/sun.nio.ch.Net.bind(Net.java:555)
        at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337)
        at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294)
        at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:141)
        at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
        at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:600)
        at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:579)
        at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
        at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260)
        at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356)
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at java.base/java.lang.Thread.run(Thread.java:840)
For complete error details, refer to the log at /opt/sonarqube-9.9.4.87374/logs/elasticsearch.log
[2024-04-13T08:17:41,126][INFO ][o.e.n.Node               ] [ip-172-31-26-106] stopping ...
[2024-04-13T08:17:41,130][INFO ][o.e.n.Node               ] [ip-172-31-26-106] stopped
[2024-04-13T08:17:41,134][INFO ][o.e.n.Node               ] [ip-172-31-26-106] closing ...
2024-04-13 08:17:41,125 pool-1-thread-1 ERROR Unable to unregister MBeans java.security.AccessControlException: access denied ("javax.management.MBeanServerPermission" "createMBeanServer")
        at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:485)
        at java.base/java.security.AccessController.checkPermission(AccessController.java:1068)
        at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:416)
        at java.management/java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:480)
        at org.apache.logging.log4j.core.jmx.Server.unregisterLoggerContext(Server.java:248)
        at org.apache.logging.log4j.core.LoggerContext.stop(LoggerContext.java:379)
        at org.apache.logging.log4j.core.LoggerContext$1.run(LoggerContext.java:320)
        at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry$RegisteredCancellable.run(DefaultShutdownCallbackRegistry.java:119)
        at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.run(DefaultShutdownCallbackRegistry.java:78)
        at java.base/java.lang.Thread.run(Thread.java:840)

uncaught exception in thread [Thread-2]
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
        at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:485)
        at java.base/java.security.AccessController.checkPermission(AccessController.java:1068)
        at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:416)
        at java.base/java.lang.ClassLoader.checkClassLoaderPermission(ClassLoader.java:2060)
        at java.base/java.lang.ClassLoader.getParent(ClassLoader.java:1807)
        at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:187)
        at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:140)
        at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:123)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:230)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:176)
        at org.elasticsearch.bootstrap.Bootstrap$4.run(Bootstrap.java:199)
elasticsearch@ip-172-31-26-106:/opt/sonarqube-9.9.4.87374/elasticsearch/bin$

Any help will be greatly appreciated
Sincere Regards
EagerToLearn

Hey there.

You should not be editing any elasticsearch.yml, jvm.options file, or trying to get Elasticsearch to run as a different user. All of this is unsupported configuration (and not in the installation guide!).

I suggest trashing your current installation, starting over, and let us know if you face any issues using the vanilla elasticsearch installation embedded in SonarQube (no config outside of conf/sonar.properties)

1 Like

So which user I should use to run sonarqube and elasticsearch?
Should I even try to run elasticsearch?

Also, can you please provide me links to installation guide of sonarqube and which version of sonarqube I should install with openjdk 17?

You should pretend Elasticsearch doesn’t exist. It’s embedded into SonarQube and all of its processes are orchestrated by SonarQube.

The SonarQube installation docs are here.

1 Like

Hi,
I did as told to delete the previous setup of sonarqube

# User credentials.
# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar

#----- Embedded Database (default)
# H2 embedded database server listening port, defaults to 9092
#sonar.embeddedDatabase.port=9092

#----- Oracle 19c/21c
# The Oracle JDBC driver must be copied into the directory extensions/jdbc-driver/oracle/.
# Only the thin client is supported, and we recommend using the latest Oracle JDBC driver. See
# https://jira.sonarsource.com/browse/SONAR-9758 for more details.
# If you need to set the schema, please refer to http://jira.sonarsource.com/browse/SONAR-5000
#sonar.jdbc.url=jdbc:oracle:thin:@localhost:1521/XE

#----- PostgreSQL 11 or greater
# By default the schema named "public" is used. It can be overridden with the parameter "currentSchema".
sonar.jdbc.url=jdbc:jdbc:postgresql://localhost:5432/sonarqube

# Binding IP address. For servers with more than one IP address, this property specifies which
# address will be used for listening on the specified ports.
# By default, ports will be used on all IP addresses associated with the server.
**# This is the IP ADDRESS of AWS iPV4 Address**
sonar.web.host=16.171.238.195


# Global level of logs (applies to all 4 processes).
# Supported values are INFO (default), DEBUG and TRACE
sonar.log.level=DEBUG


# Path to log files. Can be absolute or relative to installation directory.
# Default is <installation home>/logs
sonar.path.logs=/opt/sonarqube-9.9.4.87374/logs

  • Then I started Sonarqube
root@ip-172-31-26-106:/opt/sonarqube-9.9.4.87374/bin/linux-x86-64# ./sonar.sh restart
/usr/bin/java
Gracefully stopping SonarQube...
Removed stale pid file: ./SonarQube.pid
SonarQube was not running.
Starting SonarQube...
Started SonarQube.

Checked the logs I get this:

2024.04.15 12:39:55 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sona>
2024.04.15 12:39:55 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9>
2024.04.15 12:39:55 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [/op>
**2024.04.15 12:39:55 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running**

Any help will be greatly appreciated.