Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can't connect to gmail-imap.l.google.com,993: Connection refused

10,936 views
Skip to first unread message

computerzworld

unread,
Jun 27, 2009, 6:17:54 AM6/27/09
to patel....@gmail.com
Hello,
I am getting error like "Can't connect to gmail-imap.l.google.com,993:
Connection refused" while trying to open imap connection on the server
using imap_open. I have checked about IMAP connection on server using
phpinfo() and it displays that its on , on the server.

------------------------------------------------------------------------------------------------------------------------------
imap

IMAP c-Client Version 2004 SSL Support enabled Kerberos Support
enabled

-------------------------------------------------------------------------------------------------------------------------------

And here is my imap connection string to open imap connection.

$serverName = "{imap.gmail.com:993/imap/ssl}INBOX";

The same thing is working on my localhost. But don't know why its not
working on the server. Is there any another setting that I have to
make in order to make it work? Please help me. Thanks in advance.

The Natural Philosopher

unread,
Jun 27, 2009, 6:26:00 AM6/27/09
to

Last time this question came up, it was finally determined to be a
firewall issue at the hosting company.

So if your PHP scripts are running on a hosted host as it were ;-) check
their security policy.

'Connection refused' means that the target, or a firewall in between,
has accepted the connection request AND SENT BACK A NACK.

Its not that the request to open has got 'lost'. That STRONGLY suggests
an active agent in between you and google actively REJECTING attempts to
open mail connections.

bill

unread,
Jun 27, 2009, 6:56:13 AM6/27/09
to

Some get it to work, I am the person for whom it would not work,
even when the hosting company opened the port. But, in my case
the connection was never established.

Still no joy, I am building a local server to play with.
bill

Jerry Stuckle

unread,
Jun 27, 2009, 7:04:46 AM6/27/09
to

Check out this thread - maybe you guys are using the same isp?

http://groups.google.com/group/comp.lang.php/browse_thread/thread/126879e37a2c7c33?hl=en#

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

Jerry Stuckle

unread,
Jun 27, 2009, 7:37:07 AM6/27/09
to

Bill,

Are you sure the port is open? To you have telnet/ssh access to the
server? If so, try logging into the server and just telnet to the port.
You won't be able to do anything - but the important thing here is to
see if a connection can be established.

bill

unread,
Jun 28, 2009, 6:22:14 AM6/28/09
to
Jerry,
I do not have telnet access, but they sent a listing showing that
they did that and it worked. But I trust them as far as I can
throw them.

bill

unread,
Jun 28, 2009, 6:23:30 AM6/28/09
to
Jerry Stuckle wrote:
> computerzworld wrote:
>> Hello,
>> I am getting error like "Can't connect to gmail-imap.l.google.com,993:
>> Connection refused" while trying to open imap connection on the server
>> using imap_open. I have checked about IMAP connection on server using
>> phpinfo() and it displays that its on , on the server.
>>
>> ------------------------------------------------------------------------------------------------------------------------------
>>
>> imap
>>
>> IMAP c-Client Version 2004 SSL Support enabled Kerberos Support
>> enabled
>>
>> -------------------------------------------------------------------------------------------------------------------------------
>>
>>
>> And here is my imap connection string to open imap connection.
>>
>> $serverName = "{imap.gmail.com:993/imap/ssl}INBOX";
>>
>> The same thing is working on my localhost. But don't know why its not
>> working on the server. Is there any another setting that I have to
>> make in order to make it work? Please help me. Thanks in advance.
>
> Check out this thread - maybe you guys are using the same isp?
>
> http://groups.google.com/group/comp.lang.php/browse_thread/thread/126879e37a2c7c33?hl=en#
>
>
I am using IXwebHosting - not recommended

bill

unread,
Jun 28, 2009, 7:24:17 AM6/28/09
to
Jerry Stuckle wrote:
> computerzworld wrote:
>> Hello,
>> I am getting error like "Can't connect to gmail-imap.l.google.com,993:
>> Connection refused" while trying to open imap connection on the server
>> using imap_open. I have checked about IMAP connection on server using
>> phpinfo() and it displays that its on , on the server.
>>
>> ------------------------------------------------------------------------------------------------------------------------------
>>
>> imap
>>
>> IMAP c-Client Version 2004 SSL Support enabled Kerberos Support
>> enabled
>>
>> -------------------------------------------------------------------------------------------------------------------------------
>>
>>
>> And here is my imap connection string to open imap connection.
>>
>> $serverName = "{imap.gmail.com:993/imap/ssl}INBOX";
>>
>> The same thing is working on my localhost. But don't know why its not
>> working on the server. Is there any another setting that I have to
>> make in order to make it work? Please help me. Thanks in advance.
>
> Check out this thread - maybe you guys are using the same isp?
>
> http://groups.google.com/group/comp.lang.php/browse_thread/thread/126879e37a2c7c33?hl=en#
>
>


I sort of have it working now on my local server -
here is the command
$in=imap_open("{pop.gmail.com:995/pop3/ssl/novalidate-cert}INBOX","email@address",
"Password");

(note I am using pop3/ssl not imap/ssl)

I say sort of because I can successfully execute the script, but
it is not returning the messages.
Incremental progress.

So it appears that it was my host that was still blocking the port.

bill

bill

unread,
Jun 28, 2009, 7:31:08 AM6/28/09
to
Jerry Stuckle wrote:
> computerzworld wrote:
>> Hello,
>> I am getting error like "Can't connect to gmail-imap.l.google.com,993:
>> Connection refused" while trying to open imap connection on the server
>> using imap_open. I have checked about IMAP connection on server using
>> phpinfo() and it displays that its on , on the server.
>>
>> ------------------------------------------------------------------------------------------------------------------------------
>>
>> imap
>>
>> IMAP c-Client Version 2004 SSL Support enabled Kerberos Support
>> enabled
>>
>> -------------------------------------------------------------------------------------------------------------------------------
>>
>>
>> And here is my imap connection string to open imap connection.
>>
>> $serverName = "{imap.gmail.com:993/imap/ssl}INBOX";
>>
>> The same thing is working on my localhost. But don't know why its not
>> working on the server. Is there any another setting that I have to
>> make in order to make it work? Please help me. Thanks in advance.
>
> Check out this thread - maybe you guys are using the same isp?
>
> http://groups.google.com/group/comp.lang.php/browse_thread/thread/126879e37a2c7c33?hl=en#
>
>

I changed to imap:
$in= imap_open ("{imap.gmail.com:993/imap/ssl}INBOX",
"email@address", "Password");

and the script runs, but still says there are no messages (I know
there are two)
bill

Jerry Stuckle

unread,
Jun 28, 2009, 8:09:38 AM6/28/09
to

Whether they can do it or not is not important. The question is - can
YOU telnet from their machine to gmail port 993?

bill

unread,
Jun 28, 2009, 10:02:48 AM6/28/09
to
exactly

bill

unread,
Jun 29, 2009, 9:45:15 AM6/29/09
to
interesting, "I know there are two" was because I also have
Thunderbird set up to access the mailbox but to leave the
messages on the server. But, I guess, they are marked as read
because the script does not "see" them. When I disabled the
Tunderbird download, the script worked just fine and shows the
message and correctly downloads it.

problem solved. All it took was building my own server and LAMP
stack and considerable fussing.

computerzworld

unread,
Jun 30, 2009, 1:46:57 AM6/30/09
to
Oh many answers so far. I am having cpanel hosting on my server. So,
what should be the problem in that according to you? Because the same
thing works on my ubuntu LAMP without any problem.

Thanks.

Jerry Stuckle

unread,
Jun 30, 2009, 6:17:28 AM6/30/09
to

CPanel is a control panel for your web site. It has nothing to do with
this problem.

computerzworld

unread,
Jun 30, 2009, 7:12:33 AM6/30/09
to
On Jun 30, 3:17 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> computerzworld wrote:
> > Oh many answers so far. I am having cpanel hosting on my server. So,
> > what should be the problem in that according to you? Because the same
Yes thats right but according to previous replies I came to know that
there may be firewall that affects imap working. So, what I am asking
is that firewall should be affecting imap working? Or it may be some
other factor that will be affecting it?

> > thing works on my ubuntu LAMP without any problem.
>
> > Thanks.
>
> CPanel is a control panel for your web site.  It has nothing to do with
> this problem.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

bill

unread,
Jun 30, 2009, 7:17:08 AM6/30/09
to

It is likely that your host is blocking the outgoing port. Mine
was. However, after they said they unblocked it, it still did
not work and I gave up. Confront the support people with the
fact that your script works from home and not from their server.

bill

computerzworld

unread,
Jun 30, 2009, 9:02:49 AM6/30/09
to
Yes that is the last & final solution... I 'll confirm with my hosting
support & 'll try to figure out the problem & 'll post here what
problem i was facing... Thanks for your support.

Jerry Stuckle

unread,
Jun 30, 2009, 2:11:37 PM6/30/09
to
computerzworld wrote:
> On Jun 30, 3:17 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> computerzworld wrote:
>>> Oh many answers so far. I am having cpanel hosting on my server. So,
>>> what should be the problem in that according to you? Because the same
> Yes thats right but according to previous replies I came to know that
> there may be firewall that affects imap working. So, what I am asking
> is that firewall should be affecting imap working? Or it may be some
> other factor that will be affecting it?

Yes, it probably is a firewall - in which case you'll have to contact
your host. There is nothing you will be able to do about it; such
firewalls affect everything on the IP.

If you have ssh (or telnet) access to the host, try to telnet to the
port. You won't be able to communicate, but if you can connect at least
the firewall is open. If you can't telnet to the port from that server,
then the firewall is most probably the problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

jstu...@attglobal.net
==================

mlemos

unread,
Jul 2, 2009, 10:46:41 PM7/2/09
to computerzworld, patel....@gmail.com
Hello,

on 06/27/2009 07:17 AM computerzworld said the following:

Connection refused often means no application listening on that port on
that host, but it may also be also the server refusing connections
intentionally for some reason.

Anyway, I do not use IMAP to access Gmail mailboxes. I use POP3 with
this client class and it works well connecting to port 995 using TLS
(which is not exactly the same as SSL). Have you tried POP3 instead of IMAP?

You may want to try this class too as I am sure it works well. Take a
look at the test_pop3.php script, that has example values in comment to
instruct you how to connect to Gmail POP3 .

http://www.phpclasses.org/pop3class


--

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

computerzworld

unread,
Jul 3, 2009, 7:07:38 AM7/3/09
to
Yes I have tried both IMAP & POP3 & both are not working for me. So, I
think its something else like firewall or soemthing. I will be
contacting cpanel support for this and will try to identify the
problem and will notify it over here. Thanks.

and...@touchoftechnology.com

unread,
Dec 2, 2014, 3:49:24 PM12/2/14
to
For anyone looking for another solution if you think the firewall is already open.

https://www.google.com/settings/security/lesssecureapps

Enable access for less secure apps on your account.

Jerry Stuckle

unread,
Dec 2, 2014, 7:30:24 PM12/2/14
to
And this has WHAT to do with PHP?

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================

brian.c...@gmail.com

unread,
Aug 13, 2015, 3:29:40 PM8/13/15
to
Cant conect to gmail

moun...@gmail.com

unread,
Oct 20, 2015, 4:56:05 PM10/20/15
to

Jerry Stuckle

unread,
Oct 20, 2015, 5:13:11 PM10/20/15
to
Impossible to say since you only showed part of your code and no
messages. What's the rest (please don't include passwords)?

Are you running this from the same machine that you were using when you
accessed localhost? Are there any firewalls in the way?

What do you see in your PHP error log? And if the imap_open() fails,
what does imap_last_error() show?

ajayuk...@gmail.com

unread,
Apr 19, 2016, 5:33:07 AM4/19/16
to

bill

unread,
Apr 19, 2016, 7:32:06 AM4/19/16
to
On 4/19/2016 5:33 AM, ajayuk...@gmail.com wrote:
> On Saturday, June 27, 2009 at 3:47:54 PM UTC+5:30, computerzworld wrote:
>> Hello,
>> I am getting error like "Can't connect to gmail-imap.l.google.com,993:
>> Connection refused" while trying to open imap connection on the server
>> using imap_open. I have checked about IMAP connection on server using
>> phpinfo() and it displays that its on , on the server.
>>
...
>> $serverName = "{imap.gmail.com:993/imap/ssl}INBOX";
...
>>
>> The same thing is working on my localhost. But don't know why its not
>> working on the server. Is there any another setting that I have to
>> make in order to make it work? Please help me. Thanks in advance.
>
Thunderbird is using port 995 not 993 using SSL/TLS
bill

Thomas 'PointedEars' Lahn

unread,
Apr 20, 2016, 7:39:40 PM4/20/16
to
bill wrote:

> On 4/19/2016 5:33 AM, ajayuk...@gmail.com wrote:
>> On Saturday, June 27, 2009 at 3:47:54 PM UTC+5:30, computerzworld wrote:
>>> I am getting error like "Can't connect to gmail-imap.l.google.com,993:
>>> Connection refused" while trying to open imap connection on the server
>>> using imap_open. I have checked about IMAP connection on server using
>>> phpinfo() and it displays that its on , on the server.
>>>
> ...
>>> $serverName = "{imap.gmail.com:993/imap/ssl}INBOX";
^^^^
> ...
>>>
>>> The same thing is working on my localhost. But don't know why its not
>>> working on the server. Is there any another setting that I have to
>>> make in order to make it work? Please help me. Thanks in advance.
>>
> Thunderbird is using port 995 not 993 using SSL/TLS

Incorrect.

$ grep 99[35] /etc/services
imaps 993/tcp # IMAP over SSL
imaps 993/udp
pop3s 995/tcp # POP-3 over SSL
pop3s 995/udp

--
PointedEars
Zend Certified PHP Engineer
<http://www.zend.com/en/yellow-pages/ZEND024953> | Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

bill

unread,
Apr 21, 2016, 7:13:49 AM4/21/16
to
On 4/20/2016 7:39 PM, Thomas 'PointedEars' Lahn wrote:
>
> Incorrect.
>
> $ grep 99[35] /etc/services
> imaps 993/tcp # IMAP over SSL
> imaps 993/udp
> pop3s 995/tcp # POP-3 over SSL
> pop3s 995/udp
>

correct

ogunbowal...@gmail.com

unread,
May 20, 2017, 11:13:17 PM5/20/17
to
Problem on update my Gmail. my nokia Lumia 520has message update into for imap.gmail.com.993:1 1 tap save but it was not update verify store also tried no luck help please.

Jerry Stuckle

unread,
May 20, 2017, 11:32:16 PM5/20/17
to
On 5/20/2017 11:13 PM, ogunbowal...@gmail.com wrote:
> Problem on update my Gmail. my nokia Lumia 520has message update into for imap.gmail.com.993:1 1 tap save but it was not update verify store also tried no luck help please.
>

What is your PHP problem?

J.O. Aho

unread,
May 21, 2017, 3:32:34 AM5/21/17
to
On 05/21/17 05:32, Jerry Stuckle wrote:
> On 5/20/2017 11:13 PM, ogunbowal...@gmail.com wrote:
>> Problem on update my Gmail. my nokia Lumia 520has message update into for imap.gmail.com.993:1 1 tap save but it was not update verify store also tried no luck help please.
>>
>
> What is your PHP problem?
>

I would guess that his microsoft sponsored phone don't run PHP.

--

//Aho

Jerry Stuckle

unread,
May 21, 2017, 10:28:00 AM5/21/17
to
LOL!

Sam E

unread,
May 21, 2017, 10:59:14 AM5/21/17
to
Where's the PHP?

Reminds me of the "Where's the beef?" commercials.
0 new messages