Question

ERR_CONNECTION_REFUSED error.

Hello :)

I have a question. Now i created in Droplets new Ubuntu server. and i got a ipv4. I can login through gitlab CI/CD Pipeline with ssh command and i set to run docker container on port 5000. I can see that docker container is running on port 5000 in ubuntu terminal.

But if i try to access in browser with ipv4 it gives ERR_CONNECTION_REFUSED error. i tried to access homepage with http for example http://my-ipv4 and also http://my-ipv4:5000 but both are giving me same error.

Can you help me? :)


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Thank you for answering, I will try it as you explained.

alexdo
Site Moderator
Site Moderator badge
October 25, 2023

Hey there,

In addition to what’s already been mentioned, here are a few things you can check to troubleshoot the ERR_CONNECTION_REFUSED error:

  1. Make sure your application is bound to the correct IP address and port. This should be set to 0.0.0.0:5000 so that your application can accept connections from any IP address. Check your application’s configuration to make sure this is set correctly.

  2. Confirm that your Docker container is running and healthy. You can use the following command to see a list of all running containers:

  1. docker ps

If your container is not running, you can inspect the logs to see what went wrong:

  1. docker logs <container_id>
  1. Verify that your domain name resolves to the correct IP address. You can test this by running the following command:
  1. ping <domain_name>
  1. Check for other services that might conflict with your application. For example, if you have a web server or firewall running on port 5000, this could prevent your application from accepting connections.

  2. Try accessing your server from a different network or using a different browser. This can help rule out browser issues or local network issues.

  3. If your Docker container is running in a custom network mode, make sure that it allows external access. Containers can be set to use bridge, host, or other network modes.

Once you’ve checked all of these things, you should be able to identify the root cause of the error. If you’re still having trouble, please provide more information about your setup and I’ll be happy to offer more specific guidance.

I hope this helps!

Bobby Iliev
Site Moderator
Site Moderator badge
October 23, 2023

Hi there,

There are a few things that I could suggest checking here:

  1. Check if your Docker container is running correctly:

    • Access your container with: docker exec -it [container_name_or_id] /bin/bash
    • Check the application logs or processes to confirm it’s running and listening on the correct port.
    • Check the container logs with docker logs [container_name_or_id] and see if there are any errors
  2. Ensure Docker port binding:

    • When you run your Docker container, use the -p option: docker run -p 5000:5000 your_image_name.
  3. Firewall settings:

    First, check the status of ufw:

    sudo ufw status
    

    If it’s active and port 5000 is not allowed, you’ll need to allow it:

    sudo ufw allow 5000/tcp
    

    And then reload the firewall:

    sudo ufw reload
    

After going through these steps, try accessing your application again using http://your_ipv4:5000.

If you still encounter issues, please share any relevant error logs or configurations, and I’ll be happy to assist further!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel