Error 500 in transfer of OJS to another hosting "SQLSTATE[HY000] [1130] Host '127.0.0.1' is not allowed to connect to this MySQL server"

Hi, I have already searched in vain for the solution in this forum. I tried to move a OJS version 3.2.1-1 site to another hosting, but it only works partially. The home is visible and works, but if I try to go to the login page or in menu “archive” of home page, I get error 500. The site is in a subdomain on a shared hosting. This is what I get:

nginx: 502 bad gateway

Notice: Deprecated call without request object. in /var/www/vhosts/my-site-name.com/my-subdomain.my-site-name.com/lib/pkp/classes/template/PKPTemplateManager.inc.php on line 971

Fatal error: Uncaught PDOException: SQLSTATE[HY000] [1130] Host '127.0.0.1' is not allowed to connect to this MySQL server in /var/www/vhosts/my-site-name.com/my-subdomain.my-site-name.com/lib/pkp/lib/vendor/illuminate/database/Connectors/Connector.php:70 Stack trace: #0 /var/www/vhosts/my-site-name.com/my-subdomain.my-site-name.com/lib/pkp/lib/vendor/illuminate/database/Connectors/Connector.php(70): PDO->__construct() #1 /var/www/vhosts/my-site-name.com/my-subdomain.my-site-name.com/lib/pkp/lib/vendor/illuminate/database/Connectors/Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection() #2 /var/www/vhosts/my-site-name.com/my-subdomain.my-site-name.com/lib/pkp/lib/vendor/illuminate/database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection() #3 /var/www/vhosts/my-site-name.com/my-subdomain.my-site-name.com/lib/pkp/lib/vendor/illuminate/database/Connectors/Connecti in /var/www/vhosts/my-site-name.com/my-subdomain.my-site-name.com/lib/pkp/lib/vendor/illuminate/database/Connection.php on line 664

Thanks for help!

Hi @ojsmk3

Looks like a credentials issue. Please install adminer and confirm your mysql credentials are fine:

Take a look to this post:

Cheers,
m.

Hi, thanks for your suggestion. I will try your method and get back to you later.

What I don’t understand is that the homepage displays correctly. Shouldn’t that also depend on the database?

Upps… I read your error and I missed this part: “The home is visible and works”. :weary:

Is wired, but ojs could be reading the homepage from the cache.

Ensure credentials as told and clean caches (client and/or server) to be sure the problem is still there.

If credentials are fine and cleaning cache don’t make any change we can go ahead.

BTW, does this path exist in your new hosting?
“/var/www/vhosts/my-site-name.com/my-subdomain.my-site-name.com”

Cheers,
m.

Hello!
Thank you for the clarification! Since the site I have just transferred from the previous hosting to the new one, I don’t think it makes any sense to talk about cache, also because I tried to install it twice. Also when I try to change the database parameters, the home also disappears. So when it reappears afterwards, the browser couldn’t have taken it from the cache, right?

I also wondered if the path was right. I did the tests with a PHP script, not mine, but I could be wrong anyway. There are some parameters in config.inc.php that I don’t understand.

Cheers

I knew that error 500 was caused by the .htaccess file, but my .htaccess is completely empty, but it exists.

Maybe should I try to lower the PHP version from 7.4 to 7.3?

Thanks!

Hello ojsmk3.

Probably your hosting have another IP Address for the MySQL server, instead the common “127.0.0.1” local IP Address.

Please, call your hosting and ask for the correct IP Address Server, replacing it at config.inc.php.

NEWS: :grin:

Lowering the PHP version from 7.4 to 7.0.33 the warnings disappeared and only one error remained. Here is the error:

Parse error: syntax error, unexpected '?', Expecting variable (T_VARIABLE) in /var/www/vhosts/my-website.com/mys-subdomain.my-website.com/lib/pkp/classes/notification/PKPNotificationOperationManager.inc.php on line 374

Maybe I need to replace all instances of 127.0.0.1 with “localhost”? I just don’t know how to do it.
In config.inc.php there is only “localhost”.
Can anyone help me?
Thank you!

With the partial information I have I need to fill the gaps, so yes… there are a few rear scenarios where you can have cache issues even you are moving from one server to another:
a) in client side, if you change the server but you keep the domain.
b) in server side, if you also move the ojs cache files.
c) …

So please, confirm you clear the caches (server and client side) and please, also confir can reach your DB from Adminer as I asked before (so we will know for sure the DB host, port, name, user and pwd).

A 500 error means “something fails in the server side and I don’t know exactly what it is”. I mean, it could happen because of a lot of different causes, but yes, a wrong .htaccess (for instance with wrong mod_rewrite rules) could be related with this.

But your .htaccess is empty (btw, I suggest to delete it) don’t seams to me like the real problem.

Anyway, according to your log, you don’t have a generic 500 server side error, you have a “nginx: 502 bad gateway” error… and then a “Fatal Error” because your OJS is unable to find the mysql server in localhost (that, btw, is not a usual configuration in hosting companies). So again, this points to a misconfiguration problem (that we can check with adminer or asking your hosting company).

With the right credentials, we can take a look to your config.inc.php (annonymize and upload it to pastebin).

Finally, I don’t think will be related but you are is a 3.2.1-1 and last 3.2 stable fixes a few errors (and security issues) so I encourage you to upgrade to the last stable for your pace of mind and before we look any further.

Cheers,
m.

Not sure about OJS 3.2.1-1, but I confirm last 3.2 stable is working fine with php 7.3, so you don’t need to lower it further than this.

You only need to modify you config.inc.php but first… did you test your DB credentials? :wink:

Hi!
Sorry, I didn’t use Adminer before, as I didn’t have access to FTP. Now I used it by entering “localhost” and all the tables and other details appeared. So I deduce that using “localhost” the connection to the DB works.

If instead I use Adminer setting “127.0.0.1” I get the following error:

Host '127.0.0.1' is not allowed to connect to this MySQL server

So seems it true that you need to replace all instances of 127.0.0.1 with “localhost”. But I just don’t know how to do it.

Thanks!

True, the client-side cache stays the same, because the domain doesn’t change, so I’ll clear the browser cache. But how do you clear the server-side cache?

How do you anonymize the config.inc.php file?

Thanks for the help!

I deleted .htaccess

Cheers

Hi @ojsmk3,

No need to sorry. May be I went to fast. Let’s go step by step.

Sorry if I was not clear: “localhost” and 127.0.0.1 is the same… it won’t be the problem.

BUT, in hosting companies you don’t usually have your DB and code in “localhost”, as @henriqueramos said, they need to give you (in the cpanel or asking the support center) an IP adress for you DB host (as well as a username, DB name and pwd… and sometimes also a port).

This is why I’m asking you to use adminer to do the test. If it fails… is not an OJS issue, and you need to ask to your hosting company.

"I didn’t have access to FTP.

How did you upload your OJS to the host then? If not FTP, you will have SFTP or SSH or a cpanel file explorer. Any of this let you upload the adminer.php file (yes, is a full application in a single file) to your server and do the test I’m asking. Please, visit the post I refer in first place to know more about this.

If you don’t know how to do this, ask your hosting company.
If they don’t want to support you with this, ask them about your DB credentials because I’m almost sure “localhost” is not ok.

About how to anonymize your config.inc.php… just donwload it to your computer, open it with a text editor and replace the password variables (or whatever you feel you don’t like to share) with “xxxx” or what you like. Then, cut&paste to pastebin and place the url in this thread to let us check if something is wrong with your configuration.

After this, please, answer with yes/no (or very briefly) to each of this questions:

  1. Did you clear client cache? Instructions here.
  2. Did you clear your server’s cache? Instructions for clearing server’s data & template cache.
  3. Did you ensure your DB credentials asking your hosting company?
  4. Did you confirm those DB credentials are right with adminer?
  5. Did you upgrade your php version to (at least) 7.2? (I recommend 7.3)
  6. Did you upgrade to last 3.2 stable? (aka. 3.2.1-4 + security patch)

With this feedback we will be able to discover what is really happening.

BTW, leaving the computer now so I won’t be able to read you till tomorrow, but may be others in the forum can help.

Cheers,
m.

Hello!
@marc You are very kind to all this help. Sorry for the delay in replying, I was busy at work and I could not dedicate myself to the site.
When I said I didn’t have access to FTP it was because I was in the office, and didn’t have access to a PC.
I don’t have a webmaster, I’m trying to learn how to manage this site myself. The hosting support said that the error I reported to in this forume means that I should change all occurrences of 127.0.0.1 to “localhost”.
@henriqueramos My DB host is “localhost: 3306”

  • I cleared the browser cache.
  • I don’t understand how to clear the server caches, since it is not possible to log into the OJS site backed in any way.
  • The credentials of the DB I have chosen by myself.
  • The administrator of the yes is me.
  • I cannot raise the PHP version to 7.2 because otherwise the errors increase and become like the ones I brought at the beginning of this thread. Instead using at most, version 7.0.33 remains a single one-line error, which I report for the second time here:

Parse error: syntax error, unexpected '?', Expecting variable (T_VARIABLE) in /var/www/vhosts/my-website.com/mys-subdomain.my-website.com/lib/pkp/classes/notification/PKPNotificationOperationManager. inc.php on line 374

I will post the config.inc.php file in a few hours, because now I have technical problems.
Thanks so much!

Here is my config.inc.php code:

https://pastebin.com/8qZUFYWt

I see your triple-post for help. Please don’t do this. Filling the forum with your request is a bad practice in this community. Remember you are getting help for free from a user like you that don’t have any obligation to help, so be patient or contract paid services.

If you feel we are not moving as fast as you expect please make detailed (but brif) reports/information and been systematic with the changes… At this momment I feel some of your changes are kind of random (and not reverted) and relevant stuff is missing in your feedback. As an example, in your last post you explain:

“it is not possible to log into the OJS site backed in any way.”

Is this happening since the beginning? When it started to fail?
It’s not the same “all works except archive page” than “I can’t login and reach the backend, and archive page fails”.

Said that, please read my posts carefully and follow the instructions. Otherwise I won’t be able to understand what is happening and I won’t be able to help you.

About your answers to my questions, let’s keep a conversation sorted (and brief) to understand well each point.

1. Did you clear client cache? [closed]

Ojsmk3: Yes.

Marc: Perfect. Thanks.

2. Did you clear your server’s cache?

O: No. I can’t login in backend.

M: This is really relevant. When it started to happens?

3. Did you ensure your DB credentials asking your hosting company?

O: The credentials of the DB I have chosen by myself.

M: Ok… you can not invent the credentials by your own. You need to be completely sure or we will be losing our time here trying random stuff. This is really important before we move forward.

4. Did you confirm those DB credentials are right with adminer?

O: “The administrator of the yes is me”

M: I don’t understand what you are trying to say here. Not talking about administrator user. Adminer is a program that you need to upload to your sever to check your DB credentials. If you don’t know you could contact your hosting company and ensure those DB credentials (It means, you need a message from your hosting support telling you your DB host, DB user, DB password and (if applies) DB port because “localhost” looks like a wrong reference to your db host).
Let me be clear with this because this is important: This is the information that Henrique and I are asking you since the first post. No hard feeling here, it’s only that information is basic to advance and if don’t ensure this information I won’t be able to follow helping you.

5. Did you upgrade your php version to (at least) 7.2? (I recommend 7.3)

O: I cannot raise the PHP version to 7.2 because otherwise the errors increase and become like the ones I brought at the beginning of this thread. Instead using at most, version 7.0.33 remains a single one-line error, which I report for the second time here:

M: OJS 3.2 is able to run over php 7.2 and 7.3. Less errors in log is not necessarily better news and you like to make your site running with recent php versions… otherwise we are spending time in running it in old versions to deal with a php upgrade further. Please rise to 7.3 and upload your error log to pastebin.

  1. Did you upgrade to last 3.2 stable? (aka. 3.2.1-4 + security patch)

M: I suspect you didn’t. Let’s sort things a little before we try the upgrade.

About your config.inc.php, it looks wrong to me:

base_url = "https://www.my-subdomain.my-website.xyz/"

It need to be your real base domain name, that I suspect is:

base_url = "https://realdomain.com"

As is documented over the line you modify, this is “The canonical URL to the OJS installation (excluding the trailing slash)”.

Please, make the change, clear cache and let’s see what happens.


So, in short (and by order of importance):

  1. ENSURE your DB credentials.
  2. Modify your config.inc.ini as explained and post your log error.
  3. Upload your php to 7.2 (or better 7.3).
  4. Keep talking sorted (and been sintetic) question by question.

Cheers,
m.

Hello!
As I took 2 days to respond, I thought I caused your support to drop out. I didn’t make a triple call for help, I just tried to send a message to you. Since I don’t know how this forum works, I thought I had created a new topic by mistake. So I tried to delete it but I couldn’t, and then I tried another way to send you a message, but I got the same result as before, so I gave up. I know very well that this forum is based on voluntary help. Mine was a polite request, not a complaint or obligation. I didn’t want to post 2 more topics, I just wanted to send private messages.

  1. From the moment I migrated, login was not possible. Obviously I can access the FTP.

  2. I chose the database name, the database user name and the database password. My hosting company just forced me to use as host: “localhost: 3306”. Also in front of the name of the database and of the name of the database user there is a prefix that obviously I did not choose.

  3. I read your request wrong. I have already explained in previous posts what results I have had with the Adminer program. As the answer is long, I don’t report it here.

  4. I have ported the PHP version from 7.0.33 to 7.3.27 and the error log is as follows:

    Notice: Deprecated call without request object. in /var/www/vhosts/my-website.xyz/my-subdomain.my-website.xyz/lib/pkp/classes/template/PKPTemplateManager.inc.php on line 971

    Fatal error: Uncaught PDOException: SQLSTATE [HY000] [1130] Host '127.0.0.1' is not allowed to connect to this MySQL server in /var/www/vhosts/my-website.xyz/my-subdomain.my-website. xyz / lib / pkp / lib / vendor / illuminate / database / Connectors / Connector.php: 70 Stack trace: # 0 /var/www/vhosts/my-website.xyz/my-subdomain.my-website.xyz/lib /pkp/lib/vendor/illuminate/database/Connectors/Connector.php(70): PDO -> __ construct ('mysql: host = loca ...', 'vydeq753_PLX_ST ...', 'uf7GtyNSzP9_3Ys ...', Array) # 1 /var/www/vhosts/my-website.xyz/my-subdomain.my-website.xyz/lib/pkp/lib/vendor/illuminate/database/Connectors/Connector.php(46): Illuminate \ Database \ Connectors \ Connector-> createPdoConnection ('mysql: host = loca ...', 'vydeq753_PLX_ST ...', 'uf7GtyNSzP9_3Ys ...', Array) # 2 /var/www/vhosts/my-website.xyz /my-subdomain.my-website.xyz/lib/pkp/lib/vendor/illuminate/database/Connectors/MySqlConnector.php(24): Illuminate \ Database \ Connectors \ Connector-> createConnection ('m in / var / www /vhosts/my-website.xyz/my-subdomain.my- website.xyz/lib/pkp/lib/vendor/illuminate/database/Connection.php on line 664

  5. As I said the OJS version is 3.2.1-1 and I haven’t upgraded to higher versions because I can’t log into the site’s backend and because I don’t want to lose data.
    The real domain name was not supposed to be visible, and in the pastebin code I linked in this thread it is missing. So please delete now the real name you wrote. Thank you! In the real config.inc.php obviously the real domain/subdomain name is written, on pastebin there is no real name.

Cheers

HI @ojsmk3, it looks like you have a problem with your database connection. Unfortunately, we can not do much to help you resolve this. You will need to work with your hosting provider, who will be able to provide the necessary connection details and debug the connection on their end.

1 Like

Hi!
Hosting support examined the following error:

Fatal error: Uncaught PDOException: SQLSTATE [HY000] [1130] Host '127.0.0.1' is not allowed

And he replied that:

“This error indicates a problem with the connection to the database as in the code a call is made to ‘127.0.0.1’; on shared hosting it is not allowed to call the IP directly, but it is necessary to access” localhost ".
"I therefore recommend that you replace the instances in which you find ‘127.0.0.1’ with “localhost”. "

Support does not tell me how to replace instances ‘127.0.0.1’ with “localhost”.
Can anyone tell me how to do it?
The only replacement I have performed (“localhost:3306”) is in the database connection parameters inside the config.inc.php file. As the error remains, perhaps I should perform the replacement elsewhere, perhaps in the database tables using PHPMyAdmin?
If the database does not connect, why does the website home appear regularly?
Thanks!