Localhost ERR_CONNECTION_REFUSED

Hi. I'm completely new to elasticsearch. When i try to localhost:9200 on my browser i get a "connection refused" error. I'm posting some info, hoping they will be of any help. Thanks in advance.

This is the service error

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2020-05-08 14:47:15 CEST; 17s ago
     Docs: http://www.elastic.co
  Process: 8408 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
 Main PID: 8408 (code=exited, status=1/FAILURE)

mag 08 14:47:15 new-host elasticsearch[8408]:         at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
mag 08 14:47:15 new-host elasticsearch[8408]:         at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
mag 08 14:47:15 new-host elasticsearch[8408]:         at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125)
mag 08 14:47:15 new-host elasticsearch[8408]:         at org.elasticsearch.cli.Command.main(Command.java:90)
mag 08 14:47:15 new-host elasticsearch[8408]:         at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
mag 08 14:47:15 new-host elasticsearch[8408]:         at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
mag 08 14:47:15 new-host elasticsearch[8408]: For complete error details, refer to the log at /var/log/elasticsearch/elasticsearch.log
mag 08 14:47:15 new-host systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
mag 08 14:47:15 new-host systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
mag 08 14:47:15 new-host systemd[1]: Failed to start Elasticsearch.

This is the corresponding log

org.elasticsearch.ElasticsearchException: failed to bind service
            at org.elasticsearch.node.Node.<init>(Node.java:615) ~[elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.node.Node.<init>(Node.java:257) ~[elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:221) ~[elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:221) ~[elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) [elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) [elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) [elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) [elasticsearch-cli-7.6.2.jar:7.6.2]
            at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-7.6.2.jar:7.6.2]
            at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) [elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) [elasticsearch-7.6.2.jar:7.6.2]
    Caused by: java.io.IOException: failed to test writes in data directory [/var/lib/elasticsearch/nodes/0/indices/2vT3KPYlQ9-9dg1WFV44kA/_state] write permission is required
            at org.elasticsearch.env.NodeEnvironment.tryWriteTempFile(NodeEnvironment.java:1254) ~[elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.env.NodeEnvironment.assertCanWrite(NodeEnvironment.java:1222) ~[elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:315) ~[elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.node.Node.<init>(Node.java:277) ~[elasticsearch-7.6.2.jar:7.6.2]
            ... 11 more
    Caused by: java.nio.file.AccessDeniedException: /var/lib/elasticsearch/nodes/0/indices/2vT3KPYlQ9-9dg1WFV44kA/_state/.es_temp_file
            at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]
            at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]
            at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[?:?]
            at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219) ~[?:?]
            at java.nio.file.Files.newByteChannel(Files.java:374) ~[?:?]
            at java.nio.file.Files.createFile(Files.java:651) ~[?:?]
            at org.elasticsearch.env.NodeEnvironment.tryWriteTempFile(NodeEnvironment.java:1251) ~[elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.env.NodeEnvironment.assertCanWrite(NodeEnvironment.java:1222) ~[elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:315) ~[elasticsearch-7.6.2.jar:7.6.2]
            at org.elasticsearch.node.Node.<init>(Node.java:277) ~[elasticsearch-7.6.2.jar:7.6.2]
            ... 11 more

This is the .yml file

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# 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: ["host1", "host2"]
#
# 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.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true