LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-07-2022, 09:14 AM   #1
witchkinkofangmar
Member
 
Registered: May 2019
Posts: 83

Rep: Reputation: Disabled
curl command intermittently fails with connection refused on port 80


The error is:

Code:
curl: (7) Failed connect to 10.1.214.31:80; Connection refused
If you re-run the command, which is:
Code:
 sudo bash -c "$(curl -fsSL ipaddress:80/script.sh)"
The command might fail again with the same error, or it will run with no problem.

firewalld isn't running and selinux is disabled. There aren't any errors in the apache logs. I've restarted httpd and the vm itself. Are there any more things I can look at before asking the networking team if anything is being blocked on that end?
 
Old 09-07-2022, 10:52 AM   #2
witchkinkofangmar
Member
 
Registered: May 2019
Posts: 83

Original Poster
Rep: Reputation: Disabled
[root@]# curl --head --show-error "ipaddr"
HTTP/1.1 200 OK
Date: Wed, 07 Sep 2022 15:51:11 GMT
Server: Apache/2.4.6 (CentOS) mod_wsgi/3.4 Python/2.7.5
Last-Modified: Wed, 07 Sep 2022 15:50:03 GMT
ETag: "6-5e818441e2915"
Accept-Ranges: bytes
Content-Length: 6
Content-Type: text/html; charset=UTF-8

[root@]# curl --head --show-error "ipaddr"
curl: (7) Failed connect to ipaddr:80; Connection refused
 
Old 09-07-2022, 11:13 AM   #3
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
If it only fails sometimes then it seems either a networking or server load issue. Repeating the command should work, and sudo should not be needed with curl unless it is necessary at all times to write the output.

If you can help identify when and with what address it fails then it would be easier to trouble shoot. The "-L" option does do redirect so the failure may not have anything to do with you or the command, but may have to do with the way the initial server is performing the redirect and/or with the server and permissions at the final location.

I propose you contact the local network team since it is likely within their ballpark for the solution.
 
Old 09-07-2022, 11:15 AM   #4
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
That last post seems to show that port 80 is not open on the server. Maybe firewall or maybe address error or maybe the web server is not running.
 
Old 09-07-2022, 12:01 PM   #5
witchkinkofangmar
Member
 
Registered: May 2019
Posts: 83

Original Poster
Rep: Reputation: Disabled
Thanks.

I asked the networking team so we'll see. There shouldn't be a boundary between subnets since they're in the same VRF but who knows. Is there another log location besides /var/log/httpd/ that might show curl refused connection attempts? This is just a base install of apache to serve a few files out.

If I do an nmap to the IP, sometimes it returns with 80 and sometimes it returns without 80 (or even 22).

Nmap scan report for hostname (ipaddr)
Host is up (0.00029s latency).
Not shown: 996 closed ports
PORT STATE SERVICE
53/tcp open domain
80/tcp open http
443/tcp open https
8080/tcp open http-proxy

Nmap done: 1 IP address (1 host up) scanned in 0.28 seconds
[root@]# nmap -sT ipaddr

Starting Nmap 6.40 ( http://nmap.org ) at 2022-09-07 11:34 CDT
Nmap scan report for hostname (ipaddr)
Host is up (0.00026s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
53/tcp open domain
443/tcp open https
5000/tcp open upnp
 
Old 09-07-2022, 12:31 PM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,970

Rep: Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334
that can be a lot of things, like incorrect route, proxy, firewall or just unstable hardware (or dns error, dhcp problem or ....)
You are using VM, so this can be a problem inside the VM, or on the host or somewhere else (router?).
 
  


Reply

Tags
apache, centos 7, curl, httpd



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
curl: (7) couldn't connect to host // wget --> failed: Connection refused. linea Linux - Newbie 12 05-21-2012 12:56 PM
laptop fails to resume from suspend to RAM intermittently adityavpratap Ubuntu 2 07-12-2010 02:14 AM
SuSE 9.1 Bootup intermittently fails jimbobfruitbat Linux - Newbie 3 10-10-2004 08:57 PM
Left Shift key on keyboard fails intermittently WHY?!?! LaidBackWebSage Linux - Hardware 5 09-01-2004 03:39 PM
URPMI intermittently fails FTP downloads geesloper Linux - Software 2 06-20-2004 10:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration