1

I have website maintenance mode and it allow open just homepage. It show errors when open example categories, products and admin dashboard, Error:

1 exception(s):
Exception #0 (Exception): Unable to proceed: the maintenance mode is enabled.

I run ssh command php bin/magento maintenance:enable --ip="my ip"

So how i can use fully website when is maintenance mode enabled? This is important so i can make website fixes. I want that customers cannot see/use website when there is maintenance.

0

Please switch to production mode and try again. You can run following command to switch to production mode.

php bin/magento deploy:mode:set production

Because when developer mode is enabled, you will get such message.

  • Now it show website for me Service Temporarily Unavailable. The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. and my ip is allow use website, you see my command top. – Peter May 22 '17 at 10:22
  • From where you found your IP ? – Kishan Patadia May 22 '17 at 10:24
  • whatismyipaddress.com – Peter May 22 '17 at 10:24
  • Ok. Please open var/.maintenance.ip file and check IP there. – Kishan Patadia May 22 '17 at 10:25
  • There is right my ip. – Peter May 22 '17 at 10:25
0

To permit access to specific IP address:

php bin/magento maintenance:allow-ips 123.45.67.89

  • OR php bin/magento maintenance:enable --ip=123.45.67.89 – Frank Groot May 22 '17 at 10:22
  • Doesn't work. Production mode: Service Temporarily Unavailable. The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. – Peter May 22 '17 at 10:23
  • From where you found your IP ? – Kishan Patadia May 22 '17 at 10:23
  • Same error 503: Service Temporarily Unavailable – Peter May 22 '17 at 10:29
0

Create phpinfo() on root of your server and hit it.

You will find there one field REMOTE_ADDR copy ip from it.

And enable maintenance mode using that ip.

php bin/magento maintenance:allow-ips remote_addr_ip

Remember you'll again have to repeat same if you see maintenance mode again. As remote_addr field changed.

0

For Enable & disable of maintenance mode in magento 2, Just follow some steps:

Use the magento maintenance CLI command to enable or disable Magento maintenance mode.

Command usage:

magento maintenance:enable [--ip= ... --ip=] | [ip=none]

magento maintenance:disable [--ip= ... --ip=] |[ip=none]

magento maintenance:status

0

Problem is that when you are using Varnish as full page cache, all requests that are reaching Apache are made by Varnish, therefor the $_SERVER['REMOTE_ADDR'] will always contain the varnish IP (127.0.0.1).

One quick solution would be to edit your index.php and read a the client IP from a different key in the $_SERVER global and set it on REMOTE_ADDR

Like for example:

if (isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP']) {
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CLIENT_IP'];

} else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) { 
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}

You can at least try and see if this works.

  • Varnish will then serve the cached resources to unauthorized clients. #justSaying – vitoriodachef May 26 at 15:43
  • @vitoriodachef can you provide a use case scenario where this will happen? – Alex Dinca May 27 at 16:04
  • Sure. You are an authorized client to access a specific resource say homepage. if the homepage is cacheable, Varnish will cache it. It will then serve it to the next client that tries to access the homepage. Varnish knows nothing of authorization and is between the client and Magento. This is a known issue (github.com/magento/magento2/issues/8975). – vitoriodachef May 28 at 9:28
  • I see your point, and yes, that makes sense. However, I consider it's a separate issue than the one presented by the OP – Alex Dinca May 29 at 7:09
  • I agree. Just sharing info. – vitoriodachef May 29 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.