Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

368
Views
linux apache python cgi error: failed to get random numbers to initialize Python

My old CentOS 5 apache server can run Perl script CGI without any problem.

# cat t1.cgi
#!/usr/local/bin/perl

use CGI;
my $cgi = CGI->new();
print $cgi->header;

print "Test\n"; 



# GET HTTP://www.example.com/cgi/t1.cgi
Test

python scripts can be run under shell without any problem:

# cat t2.cgi
#!/usr/local/bin/python3

print("Content-Type: text/html\n")


print("hello!")

# python3 t2.cgi                                                                                                                                                              
Content-Type: text/html

hello!

but failed as a python cgi script:

# GET http://www.example.com/cgi/t2.cgi
<HTML>
<HEAD><TITLE>An Error Occurred</TITLE></HEAD>
<BODY>
<H1>An Error Occurred</H1>
500 Internal Server Error
</BODY>
</HTML>

apache error logs show the error was:

Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python
Python runtime state: preinitialized

Premature end of script headers: t2.cgi

any idea will be appreciated!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

fixed it by

mknod -m 444 /dev/random
chmod 444 /dev/urandom

my old centos don't have /dev/random, and the default file mode for urandom was 600, read only by root.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!