Unable to get an opensearch Curl request since running the service with systemctl

I am in the process of installing a Graylog server on Ubuntu 22.04, i have been following the official documentation and so far i have installed MongoDB and Opensearch-2.0.1. I installed Opensearch using tarball () and it is currently running without any security plugins although it is ready to go when needed. To verify it was working i opened a terminal and ran a Curl command and also opened a web browser which verified the details i want.

The next step was to run opensearch as a server with systemd. Once i did that i ran: `

 sudo systemctl daemon-reload ` `sudo systemctl enable opensearch.service` `sudo systemctl start opensearch` `sudo systemctl status opensearch` 

the last of which verifed that opensearch was now running as a service, but since then if I try to use a Curl command or a web browser it is unable to connect. The firewall is inactive so it is not blocking any traffic, I am at a loss.

I appreciate any light on this and I`m happy to answer any questions.

Thank you

curl -X GET curl: (7) Failed to connect to localhost port 9200 after 0 ms: Connection refused Created a non root user to run the service. Checked firewall rules Changed network host from private ip to 0.0.0.0 Checked logs sudo netstat -tlnp | grep 9200 to check for listening processes but there`s nothing listening to it.

1 Answer

I have solved the issue, the crux of the problem appears to be permission issues when opensearch is running as a sservice. these are the steps I did to solve it:

This is the config for the opensearch.service file:

[Unit] Description=OpenSearch After=network.target

[Service] Type=simple User=matt Group=matt WorkingDirectory=/home/matt/opensearch-2.0.1/bin Environment=OPENSEARCH_HOME=/home/matt/opensearch-2.0.1 Environment=OPENSEARCH_JAVA_HOME=/home/matt/opensearch-2.0.1/jdk ExecStart=/home/matt/opensearch-2.0.1/bin/opensearch -d Restart=always LimitNOFILE=65535 PermissionsStartOnly=true

[Install] WantedBy=multi-user.target

Next is the changing the permissions:

sudo chmod -R u+w /path/to/opensearch-2.0.1 sudo chown -R opensearch:opensearch /hpath/to/opensearch-2.0.1/logs sudo chown -R $user:group /path/to/opensearch-2.0.1/data sudo chmod -R u+w /path/to/opensearch-2.0.1/data 

If opensearch is running in the foreground or in daemonised mode it will need to be stopped before running systemctl.

pfkill opensearch 

Now to run opensearch:

sudo systemctl daemon-reload sudo systemctl enable opensearch.service sudo systemctl start opensearch.service sudo systemctl status opensearch.service curl 

Feel free to post any errors you may be getting in this thread and I will try to help.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like