sentry.exceptions.InvalidConfiguration: Error 111 connecting to redis:6380. Connection refused

Hello All,

I am new to Sentry and I am trying to install Sentry on our on-premise server, but I get the error as below.

Traceback (most recent call last):
File “/usr/local/bin/sentry”, line 8, in
sys.exit(main())
File “/usr/local/lib/python2.7/site-packages/sentry/runner/init.py”, line 165, in main
cli(prog_name=get_prog(), obj={}, max_content_width=100)
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/sentry/runner/decorators.py”, line 29, in inner
configure()
File “/usr/local/lib/python2.7/site-packages/sentry/runner/init.py”, line 128, in configure
configure(ctx, py, yaml, skip_service_validation)
File “/usr/local/lib/python2.7/site-packages/sentry/runner/settings.py”, line 158, in configure
skip_service_validation=skip_service_validation,
File “/usr/local/lib/python2.7/site-packages/sentry/runner/initializer.py”, line 328, in initialize_app
setup_services(validate=not skip_service_validation)
File “/usr/local/lib/python2.7/site-packages/sentry/runner/initializer.py”, line 370, in setup_services
service.validate()
File “/usr/local/lib/python2.7/site-packages/sentry/utils/services.py”, line 105, in
context[key] = (lambda f: lambda *a, **k: getattr(self, f)(*a, **k))(key)
File “/usr/local/lib/python2.7/site-packages/sentry/buffer/redis.py”, line 97, in validate
raise InvalidConfiguration(six.text_type(e))
sentry.exceptions.InvalidConfiguration: Error 111 connecting to redis:6380. Connection refused.
Cleaning up…

I try to run Sentry on port 6380 as 6379 is already being occupied by one of our other application running on the same server. I can see that both ports 6379 and 6380 are open based on the output below.

$ ps -ef|grep redis|grep -v grep
polkitd 1342 1318 0 15:15 ? 00:00:05 redis-server *:6379
root 7616 1 0 15:52 ? 00:00:00 redis-server 127.0.0.1:6380

Kindly advise if I am doing something wrong over here.
Please do not hesitate to let me know if any further information is needed from my end.

Any help would be appreciated.
Thanks in advance.

Best Regards

Hi!

You don’t seem to be using the setup from our on-premise repository but seem to be using some of its configs hence the issue here: the hostname redis doesn’t mean anything in your context. You either need to change this line and set the host to 127.0.0.1 or, ideally use the Docker-based on-premise setup which takes care of all these for you.

Hello,

Thank you for the prompt reply.
I use your setup from the same link you had provided.

But, I set the origin URL to our own git repo.
I had just modified certain config and saved it on our git repo.
Then I cloned our git repo on our server and have been executing the command from there.

I just execute this command on our server: ./install.sh
just like it has been mentioned here

But seems like the solution you had provided does still not work.
Now I get the below error:
sentry.exceptions.InvalidConfiguration: Error 111 connecting to 127.0.0.1:6380.

Please let me know if I am missing something, or if some more configurations are needed.
Thanks in advance.

Best Regards.

Also, How do I ensure that the Docker based setup runs Redis on port 6380?

With the Docker-based setup from our repo, the only port you need available is 9000 for the sentry web instance. All other ports are container and docker-compose network specific and should not be affected by any existing port allocations on your local machine. If you are using our repo, everything should work without any modifications on it (neither the 127.0.0.1 nor the 6380 port changes are needed).

Thank you for the prompt reply. Understood :grinning: :+1:
I will try to deploy using the Docker-based setup. will remove the file or change its name back to sentry.example.conf.py
I will, however, use the config.yml file as I have made some changes to them such as (admin email, system-url-prefix, secret-keys etc.)

1 Like

Just remove any modifications you have made in sentry.conf.py and docker-compose.yml and you should be good.

Great. It worked. Thank you for the suggestion.
sentry now works on myipaddress:9000

But I do have one minor question though.
May I know what is the purpose of system.url-prefix?
I gave system.url-prefix in config.yml to be something like

system.url-prefix: 'https://sentry.orgnization.com'

can this URL ‘https://sentry.orgnization.com’ be used to access the Sentry UI as well? or is this URL only used for other internal communication purposes?

1 Like

Glad to hear it helped :slight_smile:

system.url-prefix is used for external access and when writing/parsing URLs (including DSNs). There’s a separate setting for internal access. You can find more information about this setting over at https://docs.sentry.io/server/config/#general.

Thank you for the quick reply :slight_smile:
The issue I am facing right now is that the
system.url-prefix: ‘https://sentry.orgnization.com
is an on-premise URL which is not available from the outside network. Usually in this case, we use Azure AD urls, which acts as a reverse proxy from internet to our on-premise servers.

In this case what would be the most optimal url prefix (Root URL)?
Atleast what we observe now is that the root url is not working at the moment. Probably we might need to add a DNS to our on prem ip, but even then it will not be available in the open internet.
Should I in this case provide the External URL (Azure AD URL) as the Sentry ROOT URL?

If we want to change the ROOT URL, what is the most optimal way to do? I was not able to chage the URL in the UI. Is it possible to change using the Setry CLI?
Kindly advice.

The important question here is who needs to access Sentry (including your apps that report errors). The way they access the Sentry instance would dictate the url-prefix and the nature of your DNS records and exposure. If everything is internal then there is no need to expose Sentry or the URL to the public. If there’s even one app or user that is outside, then you’d need to expose the instance and the URL/DNS to the world via any means you have.

Thank you for the prompt reply. I believe I would need to change the url-prefix in order to make Sentry available to the open internet.
How can I change the Root URL then? what is the most optimal way to do so? I was not able to change the Root URL in the UI. Is it possible to change using the Sentry CLI?
Kindly advice.

I tried to run:

sudo docker-compose run --rm web sentry config set system.url-prefix http://sentry.newname.com

but received the following error:
AssertionError: u’system.url-prefix’ cannot be changed at runtime because it is configured on disk

Kindly advise how to change the system prefix URL?
Should I create a new topic/thread to disucss on this issue?

@naveen - just set it in your config.yml file? You get that error because you already set it in your config file as you mentioned in sentry.exceptions.InvalidConfiguration: Error 111 connecting to redis:6380. Connection refused and your earlier messages.

changing the url in config.yml and executing

docker-compose build
and
docker-compose up -d

did the trick.